• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Simple Querry

 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read this statement from Oracle8i DBA SQL and PL/SQL Study guide by Chip Dawes (Page # 31), "If you have used any operators on columns in the SELECT clause, the ORDER BY clause should have them as well". The following code seems to work fine.
================================================================
SELECT 'Name: ' | | ename "Employee Name", sal *10 "Salary", deptno
FROM emp
WHERE deptno = 30
ORDER BY deptno desc;
================================================================
Any comments???

------------------
Muhammad Farooq
Sun Certified Programmer for Java 2 Platform
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Farooq,
If I can recollect correctly, all the column names specified in the SELECT clause should be there in the ORDER BY clause.However, you can specify a column name in the ORDER BY clause, which does not appear in the SELECT clause.Hence your code snipplet should work fine.
I am not sure if you can specify composite name in the ORDER BY clause, i.e. "Employee Name" can not be specified in the ORDER BY clause.
Hope this helps,
Sandeep
 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I can recollect correctly, all the column names specified in the SELECT clause should be there in the ORDER BY clause.


nope its not the case.. its not necessary to have all names present in the select clause ...to be present in the order by clause.
 
reply
    Bookmark Topic Watch Topic
  • New Topic