Changing the order sequence

Hello,
i have a table test contains these data.
group sequence value
1 1 100
1 2 200
1 3 300
1 4 400
1 5 500
1 6 600
Now i want to change the sequence. ie, eg change the sequence of 2nd record to 5th.
ie moving the 2nd record to 5th and re arrange the sequence. so the records get rearranged
with new sequence.
3 becomes ==> 2
4 becomes ==> 3
5 becomes ==> 4
so the records should looks like
1 1 100
1 2 300
1 3 400
1 4 500
1 5 200 --> 2nd record moved to 5th
1 6 600
how can i achieve this?

create table TestTable AS
SELECT 1 group_id, 1 seq, 100 val FROM DUAL UNION
SELECT 1 group_id, 2 seq, 200 val FROM DUAL UNION
SELECT 1 group_id, 3 seq, 300 val FROM DUAL UNION
SELECT 1 group_id, 4 seq, 400 val FROM DUAL UNION
SELECT 1 group_id, 5 seq, 500 val FROM DUAL UNION
SELECT 1 group_id, 6 seq, 600 val FROM DUAL;"excahnge 2 and 5" is easy.
select group_id,seq,
case when seq = 2 then max(decode(seq,5,val)) over()
     when seq = 5 then max(decode(seq,2,val)) over()
     else val end as seq
from TestTable;"excahnge 2 to 5" is this solution.
This solution is used for ReverseSort.
select group_id,seq,val as OldVal,RevSeq - seq as a,abs(RevSeq - seq) as b,
case when seq between 2 and 5
      and RevSeq - seq  > 0 then Lead(val,abs(RevSeq - seq)) over(order by seq)
     when seq between 2 and 5
      and RevSeq - seq <= 0 then Lag (val,abs(RevSeq - seq)) over(order by seq)
else val end as newVal
from (select group_id,seq,val,
      Row_Number() over(order by seq desc) RevSeq
      from TestTable)
order by seq;update is complex.
update TestTable a set
val = (select newVal
         from (select Row_ID,
                case when seq between 2 and 5
                      and RevSeq - seq  > 0 then Lead(val,abs(RevSeq - seq)) over(order by seq)
                     when seq between 2 and 5
                      and RevSeq - seq <= 0 then Lag (val,abs(RevSeq - seq)) over(order by seq)
                     else val end as newVal
                 from (select seq,val,
                       RowID as Row_ID,
                       Row_Number() over(order by seq desc) as RevSeq
                       from TestTable)) b
        where b.Row_ID = a.RowID)
where seq between 2 and 5;

Similar Messages

  • How can I change the order of phone numbers in a contact?

    I have contacts that have more than one phone number (I am sure we all have those in this day and age). The importance of the phone numbers varies over time and I want to have the most important one as first on the list. How can I change the order that phone numbers are displayed within a contact?
    Thanks for any help.

    Currently, the order in which the phone numbers appear (in a contact) is dependent on the sequence to which you enter them. There is no way to change that order other than re-entering them in the desired order.

  • How can I change the order of the photos in a slide show I have created on my iPad mini?

    How can I change the order of the photos I have selected in a slide show on my iPad Mini?

    Currently, the order in which the phone numbers appear (in a contact) is dependent on the sequence to which you enter them. There is no way to change that order other than re-entering them in the desired order.

  • How to change the order of target message? kindly help

    Hi Experts,
              I have a source message with fields EmpNo, EmpName, Dept and joining date. The target message has the same structure but fields are in different order. That is, EmpName, Dept, EmpNo and joiningdate.
    How to achive the target message with message mapping and without using a different message type for target?
    Kindly help
    Thanks
    Gopal

    Hi Gopal,
    Try this one.
    1. Create Only one message type of target type.
    2. Go to XSD tab and export the "XSD" of the message type.
    3. Change the <xsd:sequence> element to <xsd:all>
    4. Then import the "xsd" in external definitions.
    5. Use the imported "xsd" and create Message mapping. Give both source and target the same message type from XSD.
    6. just Map one to one.
    Now you can get ur required target structure. Since it is <xsd:all> it will accept ur input file.
    Regards,
    P.Venkat

  • How to change the order of the top level navigation?

    hello,
    i don't find where i can change the order of the top level navigation.
    help would be great because there is no documentation for this issue.
    greets daniel

    If you want to define the sequence of the entry points for display in the portal, you can prioritize the entry points. You define priorities for the entry points by assigning a cetain value to each of the entry points in  the SORT PRIORITY. You may only define values greater than 0 for the priorities  and lower than 100 (default value is 100.0). The smaller the value of the entry point, the further left it moves on the navigation bar. The entry points without a priority appear in any order.
    Hope that helps,
    Frank

  • IPhoto 08: Change the order of photos in an event?

    Greetings,
    I can change the order of photos in an album, but cannot seem to figure out how to change the order of photos in an event. Any suggestions?
    Thank you for any help you can provide.

    Only way is to change the date and time of the photo (photo menu ==> adjust date and time)
    they can currently be manually moved - they stay in date-time sequence
    Larry Nebel

  • Iphoto - when exporting photos with their titles,iPhoto changes the manual sequence that I have given and imposes an alphabetical sequence

    Mac mini
    Processor  2.5 GHz Intel Core i5
    Memory  8 GB 1600 MHz DDR3
    Graphics  Intel HD Graphics 4000 768 MB
    Software  OS X 10.8.5 (12F45)
    When exporting a group photos with their individual titles, iPhoto changes the manual sequence that I have given and imposes its own sequence (which seems to be alphabetical).  The export dialogue box allows me to use my titles or to impose a numerical sequence.
    How can I keep my titles and the sequencing that I had carefully worked out?

    What you are missing is that files have no order - you view them using a program and that program creates the order
    When viewing in an iPhoto album you can sort manually and iPhoto will display the photos as you sorted them - but when you move to a different program (the finder for example) you have a totally different set of sorts available - for example in the finder the same set of files can be viewed in alpha order, in size order, in date modified order, etc - none of those are inherent in the file but are sorts set under the view menu 
    So to meet your requirements you must export with file attributes that allow the finder view options to present your desired view - which is what volunteers here have tried to help with - even though it really does not involve IPhoto in any way
    LN

  • How can I change the order in which songs appear in my iTunes Music Library?

    How can I change the order in which songs appear in my iTunes Music Library?

    Kay,
    If you are looking at the entire music library ("Music") you can sort by any of the columns by clicking the column header.  If there is a column you can't see, enable it by going to View > View Options.
    Within a playlist, you can do the same, and in addition you can click above the column of sequence numbers, which will then allow you to drag tracks up or down to get any order you wish.

  • Changing the order for printing portfolio files in adobe acrobat 9 pro

    Does anyone know how to change the order for printing pdf files that are part of a portfolio in adobe acrobat 9 pro?  The documentation seems to say that it prints files alphabetically by filename rather than by the internal sort order.  This won't work for me. Any ideas? Thanks.

    Question1: No.
    Question2: No.

  • I copied a smart playlist to a regular playlist in order to change the order of the individual selections.  I then burned the regular playlist to a cd, but the cd burned it in alphabetical order as it appears on the smart playlist.

    I changed the order, then burned a cd but the cd copied the songs in the order of the smart playlist, which was alphabetical.  What am i doing wrong in this scenario, and is there a way to change the song order in a smart playlist?  I am a new MAC user.  Is this unique to the MAC format?

    I'm trying to figure out a way to make a playlist of songs I generally like from a very large library to fit on my iPod. The songs aren't rated, and I don't want to have a totally random selection chosen by a smart playlist.
    I usually make two playlists.
    One playlist with favorites I do want on the iPod and another smart playlist to fill the rest of the iPod. Just limit the size to th esize of the iPod minus wthe size of my iPod selection playlist.

  • How do I change the order of the fields in my pdf form?

    I am using pdf. form I made in Acrobat and distributing with Adobe FormsCentral.  We use a table format for our teachers to fill out their field trip schedules and therefore use many different fields.
    How can I change the order of the fields (not for tabbing, we figured that out)...so that when we receive our notification email, I can see the inforamtion in a specific order (Date, Time, School, Program, etc).
    We would also like this same order to appear in the "View Responses" table.  I know you can drag and drop the order in the table but we have over 100 fields and that is going to take a really long time.
    Please help???
    DATE
    TIME
    To start/finish
    Name of Program  
    TEACHER’S
    NAME
    TEACHER’S EMAIL
    # OF
    STUDENTS
    Setup in
    Room #
    03-21-14
    Solids vs. Liquids
    03-21-14
    Solids vs. Liquids
    03-21-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids

    What do you mean by the "order they appear in the pdf structure"?  What is the "Pdf structure"? 
    thank you for your help... this is really upsetting, as I thought we finally found a solution with Adobe Forms : (
    We really need the fields to report back in a specific order and wouldn't have time to rearrange over 100 fields with every form that is submitted. We receive about 10-20 different forms a day (same form layout, just some of the fields will have to be prefilled depending on school/teacher reservation... so we have to name each form a different name, for each school).
    Thank you again and maybe one day they will change that.  Is there anyway to set it up in the web verison of Adobe FormsCentral to look similar to the table we have created?
    DATE
    TIME
    To start/finish
    Name of Program  
    TEACHER’S
    NAME
    TEACHER’S EMAIL
    # OF
    STUDENTS
    Setup in
    Room #
    03-21-14
    Solids vs. Liquids
    03-21-14
    Solids vs. Liquids
    03-21-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids
    04-11-14
    Solids vs. Liquids

  • I want to change the order that my 9 email accounts are listed on the left sidebar (folderpane?).

    Mac Snow Leopard
    TB 24.5.0
    Suggestions have pointed me towards finding prefs.js file, but I can't find it (library/mozilla, libary/application support/mozilla not there nor in search function)
    Tried with showing hidden files too.
    Really a pain as I need the more active accounts on top opened but not enough room with less active accounts stuck in the middle.
    No RSS feeds, local folders on bottom OK.
    Just want to change the order but can't seem to find the solution.
    Free smile to whoever helps me out! Thanks

    Use this add-on.
    https://addons.mozilla.org/en-US/thunderbird/addon/manually-sort-folders/

  • You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You can use the Menu Editor add-on to rearrange or remove menu items - https://addons.mozilla.org/firefox/addon/menu-editor

  • Can I change the order of photos in Events

    I am in the process of scanning my old film photos so that I can put them into iPhoto. As I have no scanner I take them to Wal Mart and scan them onto a CD then import them into iPhoto at home. Because the CD holds the photos from a number of events I then distribute them to a number of different Event folders.
    Once I get all the photos into their correct Event folders I would like to rearrange their order. Using drag and drop, or cut and paste, simply leaves the photo in it's original location. If I use the 'Moving photos from one event to another' feature the moved photos will still go into the new Event folder in the same order as they were in the originating folder, regardless of what order I drag or paste them.
    The help menu has topics on how to change the order of photos in a slideshow, book or calender, but not an event. I could arrange the photos beforehand so that they are scanned in the order in which I want them to appear in Events, but with 500+ photos in completely random order it will be fairly time consuming. It also will not help with the disc of photos I have already made.
    So, to finally get to my question, does anybody know if there is a way to rearrange the order of photos within an Event folder?
    Rgds

    Events are strictly time based. If you put those photos in an album and in the order you want, you can set their date and time by using the PHotos->Batch Change->Date and set the date and time you want with the checkbox to add the time differential you'd like between photos. That will reorder them in the Event also.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) 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.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.≤br>
    Note: There now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • Can I change the order of lines in a drop-down menu?

    Can I change the order of items on a drop-down menu? Specifically, the "open" menu that comes up when I right-click on a link.
    Putting "open in new tab" on top of "in new window" makes sense, of course, since it is used more often. But I do a lot of surfing, and had the old position in muscle memory. Re-training my brain to click on the first line instead of the second is taking a long time, and makes me grumbly.
    I'd love to put it back to the old order. Can I? and, if so, how do I do it? (Please give me detailed instructions, IOW, please assume I am a complete simpleton, because sometimes I am.)
    HP G62 w/ Win 7 home premium. If it matters, it's 64-bit.
    And my old desktop, which has, yech, Vista. (I haven't upgraded it to F4 yet.)
    Thanks,
    Roo

    Where is that drop-down list, on a webpage?
    Please provide a screenshot of that issue. <br />
    https://support.mozilla.org/en-US/kb/how-do-i-create-screenshot-my-problem <br />
    It is best to use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed a maximum file size of 1 MB.
    Then use the '''Browse ....''' button below the '''''Post a Reply''''' text box to upload the screenshot.

Maybe you are looking for

  • Moving Old TM Backups to a New Hard Drive

    HI, Unfortunately my 6 month old ext back up HD (Co to remain nameless) has died! I've managed to recover the TM backup folder and most of my media files with Disk Warrior. I have tried to use Disk Utility 'Restore' to image the old drive to the new

  • Rate Lookup of prior month

    Hi experts, for a modified FX calculation I need the scanned month value and the corresponding FX rate. This is well handled by the LOOKUP command of Script Logic. In addition I need the prior month value and the corresponding prior month FX rate. I

  • JDeveloper ADF Deployment to OC4J

    Have developed a UIX/JSP in JDeveloper 9.0.5.2. It works fine as expected with the JDeveloper embedded OC4J server. JSP is a master detail page, can scroll through master records and see detail lists. Deployment is successful to standalone OC4J...But

  • Sound output has DRASTICALLY changed

    Bran new macbook pro 13' came with os x 10.7.1 and I recently updated to 10.7.2 I dont know what happened but it sound as if my mid range has been scooped and my volume has been stolen. As far as I know there is no master eq settings or any other sou

  • Apple TV reboots when viewing photos and selecting slideshow mode

    Just purchased the A-TV, so only experience is with the 2.3 OS release. I can view my synced photos without issue, but when I select slideshow mode, the screen goes black for a few minutes and then the box reboots. The diagnostics state there is not