Q:

SQL Help Needed: transaction in date range one but then not in date range two for customers

I need to create a SQL statement that will show me a list of customers that purchase a product from a particular product category for period one, say July 1, 2015 thru July 31, 2015, but did not purchase a product from the same product category in period two August 1, 2015 thru August 31, 2015. 
Tables are: 
Customers: custId, fname, lname, custtype
Transactions: transid, datetrans, custid
TransItems: transid, productid, itemdescrip, quantity, price
Products: productid, productcatid, productcatgroupid
ProductCats: productcatid, productcatgroupid

What I have so far is:
SELECT  Customers.custid, 
        Customers.lname, 
        Customers.fname, 
        Transactions.transid, 
        Transactions.transdate, 
        TransItems.productid, 
        TransItems.itemdescrip, 
        TransItems.price
FROM    Transactions 
INNER JOIN
WHERE   (Transactions.datetrans BETWEEN '2015-07-01' AND '2015-07-31') 
AND     (ProductCat.productcatgroupid=2)

The next part is where I get stuck.  I need the query to then look in the date range of 08-01-2015 through 08-31-2015 and tell me if any of these customers did not have a transaction in that range after have one in the July date range. 

A:

This shows all the columns you were looking for from the July Activity that had no activity for the similar product categories by the same customer in August.   You were missing a bunch of joins between the tables to get to the final product category ID, and needed them at both the main level and the NOT EXISTS subquery.   I aliased the subquery with "2" such as T2, TI2, etc from the main query for clarification. 
SELECT  
      C.custid, 
      C.lname, 
      C.fname, 
      T.transid, 
      T.transdate, 
      TI.productid, 
      TI.itemdescrip, 
      TI.price
   FROM    
      Transactions T
         JOIN Customers C
            on T.CustID = C.CustID
         JOIN TransItems TI
            on T.TransID = TI.TransID
            JOIN Products P
               on TI.ProductID = P.ProductID
              AND P.ProductCatGroupID = 2

         AND NOT EXISTS
         ( select 
                 T2.CustID
              from
                 Transactions T2
                    JOIN TransItems TI2
                       on T2.TransID = TI2.TransID
                       JOIN Products P2
                         on TI2.ProductID = P2.ProductID
                      AND P2.ProductCatGroupID = 2
              WHERE
                     T2.CustID = T.CustID
                 AND T2.Datetrans BETWEEN '2015-08-01' AND '2015-08-31' )
   WHERE
      T.Datetrans BETWEEN '2015-07-01' AND '2015-07-31'

