Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 23rd, 2012, 10:16 AM
meo_spt meo_spt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 meo_spt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 48 sec
Reputation Power: 0
Order By In Oracle With Priority

I have a table (emp) with three columns in ORACLE:

COMPANY OFFICE EMP
------------------------
9999 00001 emp1
9999 00001 emp2
9999 00002 emp3
9999 00002 emp4
0001 99999 emp5
0001 00001 emp6
0001 00002 emp7
0002 00001 emp8
0002 99999 emp9
0003 99999 emp10
0003 00001 emp11
0003 00002 emp12


I want to get value in EMP column with following statement:

--------------
SELECT
EMP
FROM
emp
ORDER BY COMPANY (But 9999 is first), OFFICE (But 99999 is first).
-------------


I don't know how to do. Please help me do this. Thank in advance!

Reply With Quote
  #2  
Old November 23rd, 2012, 11:01 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 2,349 swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 4 Days 7 h 27 m 6 sec
Reputation Power: 390
Code:
select emp
  from emp
 order
    by case when company = 9999 then 0 else 1 end,
       company,
       case when office = 99999 then 0 else 1 end,
       office

Reply With Quote
  #3  
Old November 23rd, 2012, 12:26 PM
meo_spt meo_spt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 meo_spt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 48 sec
Reputation Power: 0
It helps me. Thank in advance!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Order By In Oracle With Priority

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap