Skip to Content
0
Former Member
Jul 15, 2013 at 11:43 AM

Distinct and order by don't work.

19 Views

Hello,

I need dates from all customers incl. faxnumbers which has orderd in the last 4 months. But I it shouldn't show double dates. How can it solved?http://www.dict.cc/englisch-deutsch/double.html

i tried this:

SELECT distinct T0.[Cardcode], T0.[CardName], T0.[DocNum], T0.[GroupNum], T0.[TaxDate], T1.[Fax]

FROM ORDR T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode

WHERE (T0.[TaxDate] >= CAST(MONTH(DATEADD(m, - 4, GETDATE())) AS varchar) + '.1. ' + CAST(YEAR(DATEADD(m, - 4, GETDATE())) AS varchar))

And this:

SELECT T0.[Cardcode], T0.[CardName], T0.[DocNum], T0.[GroupNum], T0.[TaxDate]

FROM ORDR t

join ( select Fax from OCRD T1 group by T1.[Fax]) i

ON T0.CardCode = T1.CardCode

WHERE (T0.[TaxDate] >= CAST(MONTH(DATEADD(m, - 4, GETDATE())) AS varchar) + '.1. ' + CAST(YEAR(DATEADD(m, - 4, GETDATE())) AS varchar))

Group by T0.[Cardcode]