Link to home
Start Free TrialLog in
Avatar of Sean Rhudy
Sean RhudyFlag for United States of America

asked on

Need help with a simple SQL select statement

Hello,  I have a simple sql select statement.  It worked fine before I added the WHERE clause.  I need to only select records where the SlSaleKey and SlOrigSaleKey are not the same value.
SELECT Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen)) AS SlDate
WHERE Saleline.SlSaleKey <> SaleLine.SlOrigSaleKey
FROM Saleline
GROUP BY Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen));

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is this linq?

SELECT Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen)) AS SlDate
FROM Saleline
WHERE Saleline.SlSaleKey <> SaleLine.SlOrigSaleKey
GROUP BY Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen));
your where should be below the from ^^
SELECT Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen)) AS SlDate
FROM Saleline A,Saleline B
WHERE A.SlSaleKey <> B.SlOrigSaleKey

GROUP BY A.Slcustkey, CDate(DateValue(A!SlWhen));