wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes Is the answer correct? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Is the answer correct?" Watch "Is the answer correct?" New topic
Author

Is the answer correct?

Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
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?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

Hi Sona,

If you put an exam question on the Ranch, you have to tell where you got the question from.


OCUP UML fundamental and ITIL foundation
youtube channel
Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
Its from OCP introduction to oracle 9i by Jason Couchman...
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Hi Sona,

I agree with you, and also my local 11g r1 database does.

Regards,

Fatih.
Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
Hey Fatih...

Thanks...
How ignorant of me...i forgot i can try it out. thanks for reminding me

Regards,
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you check the book's Errata? http://www.mhprofessional.com/downloads/osborne/products/0072195371/0072195371_errata.doc

Eric
swapnil kachave
Greenhorn

Joined: Feb 10, 2010
Posts: 27
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
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
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
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 459
    
    1
Correct answer is C only.

A<O><R><S (alphabetical order) <br /> <br /> >


Vinod Tiwari | Twitter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Is the answer correct?