Incorrect Syntax For Subquery

Babak

Registered User.
Local time
Today, 07:09
Joined
Jul 29, 2013
Messages
16
SELECT Line, Downtime
FROM [Top 3 DownTime]
WHERE Downtime IN (
SELECT TOP 3 Downtime
FROM [Top 3 DownTime] as S
WHERE S.Line = [Top 3 DownTime].Line
ORDER BY Downtime DESC
);
This is my subquery. For some reason, I am getting an inccorect syntax error. "Top 3 Downtime" is my table and "Line" and "Downtime" are two fields in that table.
 
Yank that puppy apart and see where it breaks. I know you called that entire thing you're subquery, but itself has a sub-query (where that second SELECT clause starts). Does that sub-query work? If not, what errors?

Divide and conquer. (hint: once you give something an alias, its original name is no longer available.)




 
I got it to work, thanks for the help guys.
 

Users who are viewing this thread

Back
Top Bottom