BHUC
asked on
Find customers who ordered in 2015 but not 2016
I have a table called Passes1 that shows every ticket sale we have ever made.
I want to run a query on customers that bought a ticket in 2015 but have not bought yet in 2016
I have this query -
SELECT * FROM Passes1 as pa WHERE NOT EXISTS (Select * from Passes1 as pa1 WHERE pa.THID=pa1.THID AND pa1.Year = '2016') AND Year ='2015'
Where am I off?
I want to run a query on customers that bought a ticket in 2015 but have not bought yet in 2016
I have this query -
SELECT * FROM Passes1 as pa WHERE NOT EXISTS (Select * from Passes1 as pa1 WHERE pa.THID=pa1.THID AND pa1.Year = '2016') AND Year ='2015'
Where am I off?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...more likely than a Year column you would have an orderdate column and would pick MAX(YEAR(orderdate)) = 2015
Bye, Olaf.
Bye, Olaf.
Open in new window