how records which dont match the date year sequence I am trying to return all customer records who have NOT ordered every year without fail.
Eg,
cust1 - 2010
cust1 - 2012
cust1 - 2013
cust1 - 2014
cust2 - 2014
As you can see cust1 has not ordered in the year 2011
I would like to return the row that shows cust1.
I need to be able to specify a sequence of dates, eg min and max.
I have tried this:
DECLARE @MINDATE AS INT;
SELECT @MINDATE = '2010';
DECLARE @MAXDATE AS INT;
SELECT @MAXDATE = '2014';
SELECT CUSTID, YEAR(DATE) AS [YEAR]
FROM ORDER
WHERE DATE BETWEEN @MINDATE AND @MAXDATE;