0
Why we need to add all ORDER BY column names in SELECT clause when we are using DISTINCT in SELECT?
Example : Following first query execute but second prompt error. 1] SELECT DISTINCT EId, Email, FirstName, LastName FROM Employee WHERE FirstName ='Yash' ORDER BY FirstName, LastName 2] SELECT DISTINCT EId, Email, FirstName FROM Employee WHERE FirstName ='Yash' ORDER BY FirstName, LastName
1 Respuesta
+ 7
because you don't select Last Name but you try to order by it in the second.
order by works on the "extracted" data, not on the original table (database), so if you did not include it in the Select it just does not exist for it.