Where in the order by

I need to sort the order by with a value of one of the fields, not asc or desc, but by a specific value. Is that possible?

I too am having some problems understanding what you are wanting exactly... but is this it? Bit of a hack.. but I think it works the way you want it to.
CREATE TABLE JOBS
(DEPT_NUMBER NUMBER
,JOB_TITLE VARCHAR2(100)
,JOB_NUMBER NUMBER
,JOB_LOCATION VARCHAR(50)
INSERT INTO JOBS
SELECT
TRUNC(DBMS_RANDOM.VALUE(1,20)) DEPT_NUMBER
,DBMS_RANDOM.STRING('U',1) JOB_TITLE
,TRUNC(DBMS_RANDOM.VALUE(1,20)) JOB_NUMBER
,DBMS_RANDOM.STRING('U',2) JOB_LOCATION
FROM
DUAL
CONNECT BY LEVEL <= 500
INSERT INTO JOBS
SELECT
TRUNC(DBMS_RANDOM.VALUE(1,20)) DEPT_NUMBER
,'A' JOB_TITLE
,TRUNC(DBMS_RANDOM.VALUE(1,20)) JOB_NUMBER
,'MAIN OFFICE' JOB_LOCATION
FROM
DUAL
CONNECT BY LEVEL <= 20
COMMIT;
SQL> VARIABLE INPUT VARCHAR2(50);
SQL> EXEC :INPUT := 'MAIN OFFICE';
PL/SQL procedure successfully completed.
SQL> SET ECHO ON
SQL> SELECT * FROM JOBS WHERE JOB_TITLE='A' ORDER BY DECODE(JOB_LOCATION,:INPUT,'AAAA111'||JOB_LOCATION,JOB_LOCATION),DEPT_NUMBER;
DEPT_NUMBER JOB_TITLE  JOB_NUMBER JOB_LOCATION
          1 A                   9 MAIN OFFICE
          3 A                  12 MAIN OFFICE
          3 A                   2 MAIN OFFICE
          4 A                  17 MAIN OFFICE
          5 A                   8 MAIN OFFICE
          7 A                  12 MAIN OFFICE
          7 A                   2 MAIN OFFICE
          7 A                  13 MAIN OFFICE
          7 A                   4 MAIN OFFICE
          8 A                   1 MAIN OFFICE
          9 A                   3 MAIN OFFICE
          9 A                  13 MAIN OFFICE
         10 A                   4 MAIN OFFICE
         10 A                   5 MAIN OFFICE
         11 A                   7 MAIN OFFICE
         12 A                  17 MAIN OFFICE
         13 A                  14 MAIN OFFICE
         13 A                   8 MAIN OFFICE
         14 A                   4 MAIN OFFICE
         19 A                   6 MAIN OFFICE
         13 A                  12 BF
          6 A                   8 ET
         10 A                   9 MO
         19 A                  14 NU
         16 A                  19 PE
         17 A                  15 QT
         14 A                   6 SO
         11 A                  16 ST
         15 A                  18 WF
         13 A                  12 XU
          8 A                  10 YT
          6 A                  12 ZQ
32 rows selected.
SQL>So basically, whatever you pass as the office job location is forced to the top of the list.
Like I said, a hack, but works (for now).

Similar Messages

  • Where is the 'order number' on the box of the education version of Adobe Creative Suite 6?

    I bought this from the Apple store today and I am trying to prove my student eligibility online but cannot locate the 'order number' it is asking for, does anyone know where this is?

    Contact S&T support by phone or web chat.
    Mylenium

  • Where do the orders come fr

    I was wondering where the stuff comes from when you order something from this site. Ive ordered an mp3 player and cant wait till it comes.

    Which site did you order from? Which country are you in?
    I'm afraid you're going to have to change that signature. The moderators here use the Get Creative signature, this would just confuse people.
    Cat

  • Purchase made in store, to be delivered, where is the order on website

    I purchased a TV at a store, got email today with order number stating that tv was on its way to store for me to pick up.  Why can't I find any mention of this order on the website?  
    And, every time I log into the website, I have to create a new password.  This website is really getting bad.

    Hi jwdesselle,
    If you placed your order at an in-store register, then this may explain why you aren't able to view its progress -- in-store purchases cannot be tracked on BestBuy.com. Account access issues can also be caused by missing or invalid information, such as e-mail addresses, telephone numbers and billing addresses.
    No need to worry though! I was able to locate your order using the e-mail address you used to register for the forum and your TV appears ready for pickup. I've also addressed the issue preventing you from signing into BestBuy.com and have reset your account's password. When you sign back in, please do the following in order:
    Log out of your BestBuy.com account completely on all devices, including the My Best Buy app
    Delete your browser history, cache, and cookies
    Visit the password reset link in your email (please be sure to check your spam folder)
    Create a new password that fits the accepted criteria (use a password you’ve never used before)
    Logout of your account as it will log you in automatically after creating the new password
    Wait 5-10 minutes and then attempt to login to your account
    Let us know if you have any other questions or if you need any additional assistance.
    Aaron|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Where in the order of editing a photo in Elements 9 would you add Noise Ninja?

    The company says it is best to do it as early as possible, but when you are editing the photos in raw in Photoshop Elements, i would assume that you should finish off the editing in raw first, and then going to The Elements Editor and reduce the noise at that time?  Would you use the sharpening with Noise Ninja or sharpen it as i have done within the scope of Elements, both in raw and post sizing the photos? 
    Ron

    When your photo is in the RAW editor (ACR), you can use the Noise Reduction settings on the Details tab.  Then, as soon as it's in PSE, use PSE's Noise Reduction filter or Noise Ninja.
    I prefer to do any sharpening as the last step, either with PSE's tools or a 3rd party add-in.
    Ken

  • I need an Apple SuperDrive 8X Part No. 661-4279 for my MacBook Pro.  Where is the best place to order one?

    I need an Apple SuperDrive 8X Part No. 661-4279 for my MacBook Pro.  Where is the best place to order one?

    Some sites to check out.
    http://www.powerbookmedic.com/Apple-SuperDrive-DVD-Burner-Drive-8x---Macbook-Pro -p-16916.html
    http://www.macpartsonline.com/661-4279-superdrive-8x-double-layer-pata-15inch-2- 2-2-4-2-6ghz-macbook-pro-a1226.html
    http://www.dvwarehouse.com/661-4279-DVD-R/CD-RW-SuperDrive-8x-Dual-Layer-PATA-fo r-MacBook--MacBook-Pro---NEW-p-37374.html
    http://www.welovemacs.com/6614091r.html

  • How can I figure out where are the heaviest volumes in order to get rid of the useless stuff?.

    How can I figure out where are the heaviest volumes in order to get rid of the useless stuff?.

    How about a few specific NOUNs to replace the vague references you have made. A little context.
    Volumes of WHAT ?
    What sort of STUFF are you trying to eliminate ?

  • I tried to rent a film on my MacBook but it comes up with, In order to rent, you need to authorise this computer. To authorise this computer, select "Authorise Computer..." from the store menu. Where is the store menu and how do I sort it?

    I tried to rent a film on my MacBook but it comes up with, In order to rent, you need to authorise this computer. To authorise this computer, select "Authorise Computer..." from the store menu.
    Where is the Store menu and how do I authorise my computer?
    Please help.
    Thank you.

    Move the cursor to the very top of the computer's screen, click on Store in the menu bar, and choose Authorize this Computer.
    (115518)

  • How do you keep the order using SELECT WHERE IN()?

    Hi,
    Is there a way to keep the order when using SELECT WHERE IN()? For example, using the following query:
    SELECT id FROM data_table WHERE id IN('56','55','54','1','7');
    The results will come back using the default order by id. 1,7,54,55,56
    When I want to keep the order used in the IN: 56,55,54,1,7
    Is there a quick way to do this in mySQL or will I be forced to order it after in code.
    Thanks

    797836 wrote:
    Hi,
    Is there a way to keep the order when using SELECT WHERE IN()? For example, using the following query:
    SELECT id FROM data_table WHERE id IN('56','55','54','1','7');
    The results will come back using the default order by id. 1,7,54,55,56In case the order by docs and comments weren't clear on this point, there is no default order and they may come back in a different order. Usually after you've tested it to exhaustion to prove otherwise, then put it in production.
    >
    When I want to keep the order used in the IN: 56,55,54,1,7
    Is there a quick way to do this in mySQL or will I be forced to order it after in code.
    ThanksUsing the in list allows oracle to have other possible data access paths than simply running the query 5 times. If for whatever reason you don't want to order the results after they come back, it may be worth your while to just run the five queries serially in the order you want, using bind variables and so having identical queries. That may seem silly on its face, but then again, we don't know the real requirements, what else is going on, if this is simplified from the real code or whether there will always be 5.

  • Does the Order of the tablesjoins in Where clause matter in ORDERED hint?

    The ORDERED hint requests that the tables listed in the FROM clause of a SQL statement be joined in the order specified. But does the order of the join in "where" clause matters?
    Will be there any performance difference between below query? The order of the table in the FROM clause remains the same, but there is a difference in the order of conditions in the WHERE clause
    SELECT /*+ ORDERED */ a.fp_i f
    FROn iw_owner.revenue_fpct b,
    dw_owner.fp_dinn c,
    dw_owner.nanaged_at_dinn a,
    dw_owner.at_dinn_curr d,
    iw_owner.na_progran e,
    dw_owner.fp_dinn_curr f,
    dw_owner.fpn_of_at_dinn g
    WHERE a.nacc_dinn_i = b.nacc_dinn_i
    AND b.fp_dinn_i = c.fp_dinn_i
    AND a.acc_i = d.acc_i
    AND a.acc_nacc_c = e.npn_pro_c
    AND a.fp_i = f.fp_i
    AND b.org_fpn_dinn_i = g.org_fpn_dinn_i(+)
    AND c.fp_i IN ('JG 04')
    AND b.dte_dinn_i BETWEEN '1-Apr-2011' and '30-Apr-2011'
    SELECT /*+ ORDERED */ a.fp_i f
    FROn iw_owner.revenue_fpct b,
    dw_owner.fp_dinn c,
    dw_owner.nanaged_at_dinn a,
    dw_owner.at_dinn_curr d,
    iw_owner.na_progran e,
    dw_owner.fp_dinn_curr f,
    dw_owner.fpn_of_at_dinn g
    WHERE c.fp_i IN ('JG 04')
    AND b.dte_dinn_i BETWEEN '1-Apr-2011' and '30-Apr-2011'
    AND b.fp_dinn_i = c.fp_dinn_i
    AND a.nacc_dinn_i = b.nacc_dinn_i
    AND a.acc_i = d.acc_i
    AND a.acc_nacc_c = e.npn_pro_c
    AND a.fp_i = f.fp_i
    AND b.org_fpn_dinn_i = g.org_fpn_dinn_i(+)
    Thanks

    Gangadhar Reddy wrote:
    Does it matter the order of first 2 tables?This question makes me really wonder. It's fairly easy to see how explain changes when using hints.
    Your question indicates that you do not look at explain plans?
    Then why are you asking about hints in the first place?
    Using hints is something you do when you want to force a specific execution plan as part of some investigation, because you know something that the optimizer does no, or you have found a bug in the optimizert.
    In all cases you know exactly what you are doing.
    The /*+ ORDERED */ is all about you telling the optimizer to join the tables in the order you specified them in the from clause.
    As to your original question, there exists a similar ORDERED_PREDICATES hint.
    Regards
    Peter

  • Where is the Shuffle slide order button in iPhoto 6?

    Where is the Shuffle slide order button in iPhoto 6? - I don't see one...
    Click Settings at the top of the Slideshow dialog to set one or more of the following options:
    ** where is this button? ****---> Select "Shuffle slide order" to play slides in random order.

    Rev:
    In iPhoto 6 there is no Shuffle option in the slideshow mode. However, if you select an album or a number of photos in the library and use the Play button in the toolbar at the bottom there will be a Shuffle option in the Settings window. That's the only place you'll be able to shuffle the slides.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.

  • Where is the best place to store Contacts in order to later print labels and such?

    Where is the best place to store contacts in order to later print labels etc?

    I found this excellent article last week describing how to print labels from your Mac's Contacts application:
    How-to: Print customized address labels for holiday card envelopes ...

  • Where is the "Manage Pre-Orders" option?

    Where is the "Manage Pre-Orders" option?

    OK, so only if you have Pre-Orders you will see the option. I thought I have some but I guess I don't.
    Thanks.

  • From where does  Purchase Order picking the Tracking number.

    Hi Experts,
    Can some one tell me, from where the Tracking number is picking in Purchase Order transaction.
    Is there any specific settings to check.
    I Have created one PO, In Item level I can see tracking number *******. could any one of you tell me  where does the system pick the tracking number from?
    Thank You.

    I Can not see the default value button anywhere.
    I need to get the Tracking number in PO.
    However when I am trying with different vendor with Pur. Org I am able to get the Tracking number in the PO but I am unable to get the Tracking number with other Vendor and Purch. org combination.
    Is there any specific settings to exist the tracking number.
    Thank You.

  • Where is the code of Apply button (the update page of change order)

    Hi,
    Actually, it is the Apply button of the update page (the attribute of the lines revised item of the change order).
    I read the 9 controllers code that listed in the 'About this Page', but I cann't find where is the Apply button's... :(
    I try to find it in the dev environment, but after clicked the 'Apply' button, the dev server throws a exception(it is posted in the thread how to fix exception in dev enviorment, while it's ok in dev instance
    The ebs version is 12.0.4. If you are interested with the problem and you can access the bugDB, you can check the detail about the bug# 7582452.
    Any helpful suggestion are welcome.
    Thanks
    Qinhua

    The problem is settled down at 12-11, the actual code of the apply button is at other source file, the OAF forward the action to other file, so we can't find the code at the source files that listed in the source file.
    The following is the abstract forward chain of the action:
    OAWebBeanHelper.processFormData -> OAWebBeanFormElementHelper.setValue -> ViewRowImpl.setAttribute -> EntityImpl.setAttribute -> EgoMtlSyItemChangesEOImpl.setAllowSubstituteReceiptsFlag
    From the chain, I guess the OAF will forward the data to the entity source file(XXEOImpl) to complete the action and submit it to database.
    So, maybe we can check the corresponding EOImpl of the entity to find the action code.

Maybe you are looking for

  • Connecting MBP to G4 with ethernet

    Since acquiring a MacBook Pro in May, I have been unable to get it to connect via ethernet to the G4 laptop on the same network. Both laptops have a Location on which Appletalk is operational. Personal file sharing is activated on both. I use the Con

  • IMovie won't import gameplay files from Elgato.

    I recently got an HDPVR (The Elgato Game Capture HD) to record gameplay from my Xbox 360. I recorded about an hour of gameplay and used the Elgato's software to import the file into iMovie. It began it's import but got hung up on a part that said "Ge

  • Have a new computer need all my itunes purchases put on this new computer

    my computer was stolen and i need to get all my itunes purchases on my new computer how do I do that?

  • Rpd Modeling-Forecast Measures

    Hi, I have a reporting requirement to display Revenue, Cost forecasts for 3months, 2months and 1 months from the current month. Could you please help me in modeling this scenario at rpd? These are few details that might help: 1) the Revenue and Cost

  • Where is my stationary?

    Where is my stationary--since upgrading, I can't find it or add it to my toolbar?