Hi...
I am reading about using 'order by' clause. I came across following question -
The results from an SQL query are shown here.
Which of the following SQL statements could not have produced this output?
A. select deptno,dname,loc from dept order by 2 asc, 1 asc, 3 desc;
B. select deptno,dname,loc from dept order by 3 asc;
C. select deptno,dname,loc from dept order by 2 asc;
D. select deptno,dname,loc from dept order by 2 asc, 3 asc, 1 desc;
I think correct ans is (B.). But book says it is (C.). What do you think?
This message was edited 2 times. Last update was at by Bear Bibeault
This message was edited 1 time. Last update was at by Eric Pascarello
swapnil kachave
Greenhorn
Joined: Feb 10, 2010
Posts: 27
posted
0
order by 2 asc means it doing order by dname in ascending order.
if you check the alphabetic order of colom 2 you will find the answer c is right.
if you are saying the answer is (b) then check the order by statement which say order by LOC in ascending order. which is not in alphabeticall order so that answer (c) is right.
Sona Patel
Ranch Hand
Joined: Mar 30, 2009
Posts: 75
posted
0
Hi Swapnil...
Option (A),(C),(D) will produce the output as shown in the question.
Option (B) will not produce the same output right ??
Question is :
Which of the following SQL statements could not have produced this output?
So the ans is (B) could not have produced the same out put.
swapnil kachave
Greenhorn
Joined: Feb 10, 2010
Posts: 27
posted
0
Sona Patel wrote:Hi Swapnil...
Option (A),(C),(D) will produce the output as shown in the question.
Option (B) will not produce the same output right ??
Question is :
Which of the following SQL statements could not have produced this output?
So the ans is (B) could not have produced the same out put.
Yes..
If you go for b then check the order by clouse where you specify the different column no and output not contain that column in sorted oreder