79399580

Date: 2025-01-30 10:43:15
Score: 0.5
Natty:
Report link

As far as I know in T-SQL (and most likely Sybase) you cannot use order by clause in sub-query, derived table and view unless using Top n for example the following query will result an error message in T-SQL:

SELECT TOP 1 P.FirstName, P.LastName, (SELECT E.Title FROM Education E WHERE P.ID = E.PersonId ORDER BY E.StartDate DESC) 'LastEducationLevel' FROM Person P

However this one will be executed successfully:

SELECT P.FirstName, P.LastName, (SELECT TOP 1 E.Title FROM Education E WHERE P.ID = E.PersonId ORDER BY E.StartDate DESC) 'LastEducationLevel' FROM Person P

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: gyousefi