Skip to Content
0
Former Member
Jun 09, 2009 at 09:32 AM

Query suggestions / help

25 Views

Hi @ll,

I am creating a query for searching order / invoices. Only customers should be displayed, who ordered least 90 days before and there is no order for a earlier time.


SELECT MAX(T0.DocDate), T0.CardCode FROM OINV T0 
WHERE DATEDIFF(day, MAX(T0.DocDate), getdate()) <= 90 
GROUP BY T0.CardCode, T0.DocDate 
ORDER BY T0.CardCode, T0.DocDate DESC 

Datediff works well, but not with the MAX statement. If i use only Datediff(day, T0.DocDate, getdate()) = 90, it displays also customers, who ordered in a earlier time.

Regards Steffen