• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is the answer correct?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sona,

If you put an exam question on the Ranch, you have to tell where you got the question from.
 
Sona Patel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its from OCP introduction to oracle 9i by Jason Couchman...
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sona,

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

Regards,

Fatih.
 
Sona Patel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Fatih...

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

Regards,
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check the book's Errata? http://www.mhprofessional.com/downloads/osborne/products/0072195371/0072195371_errata.doc

Eric
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 466
1
IntelliJ IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct answer is C only.

A<O><R><S (alphabetical order) <br /> <br /> >
reply
    Bookmark Topic Watch Topic
  • New Topic