1. The ORDER BY clause uses the column of the first SELECT query.
2. By default, the first column of the first SELECT query is used to sort the ouput in ascending order.
3. The ORDER BY clause accepts the column name or an alias.
4. You can use ORDER BY clause only once in a compound query.
5. The ORDER BY clause does not recognize the column names of the second SELECT query. To avoid confusion over column names, it is common practice to ORDER BY column positions.
@cspro2410
A)If your running both select without order by means it will union and return only 2 columns and after giving order by 1,2 it will run successfully. This is because 1,2 represents two columns.
B)In here it will union and it return one column only but in order by its given 1,2 so will fail
C)Here it will union and it return one column but order by is happening on 3rd column
D)Here union and it return two columns but order by happening on 3rd,4th column
so a is correct
C is not correct since the second element tries to "order by 3". This means that the parser is trying to order by the 3rd element in the select clause. However, there's only 2 elements.
you mean 1 element
it is sorting only from the elements from the 1st select
upvoted 1 times
...
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
super04
5 months, 1 week agozouve
7 months, 1 week agoChandru007
1 year, 1 month agocspro2410
1 year, 1 month agoManAtWar
1 year agozouve
6 months, 2 weeks ago