June 4, 2020 at 12:00 am
Comments posted to this topic are about the item Minus Query
June 4, 2020 at 12:22 pm
Pretty sure the restriction on ORDER BY is on the UNION, not the EXCEPT and INTERSECT. Can anyone confirm?
June 4, 2020 at 2:04 pm
The order by is not allowed for an EXCEPT, and neither allowed for a UNION.
June 4, 2020 at 2:47 pm
Order by must not be used on the first query whenever you are using except,intersect or minus query.
But you can use order by in the second query.Order by in the second query is to sort the final result.
Hall of Fame
June 4, 2020 at 8:04 pm
ORDER BY FIRSTNAME;
Stewart "Arturius" Campbell
June 5, 2020 at 11:17 am
Nice question, thanks
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Mr or Mrs. 500
June 5, 2020 at 6:05 pm
The ORDER BY can only appear after the second query in an EXCEPT or INTERSECTION operator and only reference columns from the left (first) query.
This would work:
FROM @EMPLOYEE E
FROM @PERSON P
ORDER BY E.FIRSTNAME
This would throw an error:
ORDER BY P.FIRSTNAME
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply