[RESOLVED]Help with ORDER BY Clause

I need help with ordering my Inner Select query by its Date.  

Here’s the query

SELECT * FROM UserProfile WHERE UserID IN (SELECT User_ID FROM following WHERE UserID=@0 ORDER BY FDate DESC)

I keep getting this error

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

Try this

SELECT * FROM UserProfile WHERE UserID IN (SELECT User_ID FROM following WHERE UserID=@0) ORDER BY FDate DESC

Leave a Reply