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

Sean RhudyPresidentAsked:
Who is Participating?
 
chaitu chaituCommented:

 SELECT Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen)) AS SlDate
FROM Saleline
WHERE Saleline.SlSaleKey <> SaleLine.SlOrigSaleKey

GROUP BY Saleline.Slcustkey, CDate(DateValue(Saleline!SlWhen));
 
0
 
kerwinsiyCommented:
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));
0
 
kerwinsiyCommented:
your where should be below the from ^^
0
 
chaitu chaituCommented:
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));
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.