Update statement w / Order By and other goodies

It is a continuation of my previous post: Re: create the update with joint statement / select please see for table structure and sample data.

OK, so this is based on my previous question SQL that has been resolved by you brilliant SQLers there. the code below will do exactly what I need it to do, but I wanted less user interaction:
update offender_case_identifiers ociq
   set Identifier_type = 'ARN2'
 where ociq.offender_book_id in
      (select offender_book_id from v_header_block
        where offender_id_display = :ppid)
    and ociq.comment_text != :parn
   AND ociq.identifier_type = 'ARN'
I wanted only the user having to enter in the ": pid" and have the script to take care of the rest. I found the best way to ensure that I find the most recent "RNA" of the offender_case_identifiers (which will then need to be set on ": bcyr ') is to run the following script:
select oci.identifier_type 
, vhb.offender_id_display
,oci.comment_text
,vhb.offender_book_id
,oci.offender_book_id
from   offender_case_identifiers oci, v_header_block vhb 
where 
oci.offender_book_id = vhb.offender_book_id
and vhb.offender_id_display = :ppid
and oci.identifier_type like 'ARN'
order by comment_text desc
The code above was the original starting point for my last final SQL command, mentioned first in this post, however, I added the 'ORDER BY' the bottom of it. For additional examples of data, here is the result of the above statement:

IDENTIFIER_TYPE OFFENDER_ID_DISPLAY COMMENT_TEXT OFFENDER_BOOK_ID OFFENDER_BOOK_ID_1
RNA * 0000382183 * 01550228 * 1 011 683 * 1 011 683
RNA * 0000382183 * 01550228 * 1 011 683 * 1 011 683
RNA * 0000382183 * 01531810 * 823 281 * 823 281
RNA * 0000382183 * 01531810 * 823 281 * 823 281
RNA * 0000382183 * 01531810 * 823 281 * 823 281
RNA * 0000382183 * 01531810 * 823 281 * 823 281
RNA * 0000382183 * 01529717 * 804 301 * 804 301
RNA * 0000382183 * 01525871 * 759 982 * 759 982
RNA * 0000382183 * 01525871 * 759 982 * 759 982
RNA * 0000382183 * 01516263 * 688 100 * 688 100
RNA * 0000382183 * 01516263 * 688 100 * 688 100
RNA * 0000382183 * 01516263 * 688 100 * 688 100
RNA * 0000382183 * 01515789 * 682 680 * 682 680
RNA * 0000382183 * 01510809 * 624 140 * 624 140
RNA * 0000382183 * 01507681 * 590 261 * 590 261
RNA * 0000382183 * 01507681 * 590 261 * 590 261
RNA * 0000382183 * 01507681 * 590 261 * 590 261
RNA * 0000382183 * 01484993 * 454 927 * 454 927
RNA * 0000382183 * 01484993 * 454 927 * 454 927
RNA * 0000382183 * 01484993 * 454 927 * 454 927
RNA * 0000382183 * 01477592 * 448 231 * 448 231
RNA * 0000382183 * 01477592 * 448 231 * 448 231
RNA * 0000382183 * 01456544 * 428 902 * 428 902
RNA * 0000382183 * 01456544 * 428 902 * 428 902
RNA * 0000382183 * 01429778 * 403 175 * 403 175
RNA * 0000382183 * 01427677 * 401 055 055 * 401
RNA * 0000382183 * 01427677 * 401 055 055 * 401
RNA * 0000382183 * 01427677 * 401 055 055 * 401

I therefore, as you can see, the query to select the recording of top/1 St 'Comment_Text' in the above results, and give it the ': bcyr ' WITHOUT inviting the user to enter. So I want the script to change all the other "Identifier_Type' to"ARN2"who do not share the first 'Comment_Text'... so in this example, I want all the"RNA"replaced by"ARN2"who do not have 'Comment_text' = 01550228.


I hope that's not too complicated, because it is to me. Thanks in advance for any assistance.

Hello

If you have a query that displays all rows, and you want to UPDATE the lines in this updated reuslut who do not have the highest value of comment_text. You can use the analytic DENSE_RANK function to number the separate comment_texts and then throw the lines that have been assigned to #1. the rest will be those you wqant to UPDATE.

Here's a way to do it:

UPDATE     offender_case_idetifiers
SET     identifier_type     = 'ARN2'
WHERE     (offender_book_id, comment_text)
     IN (
            WITH    got_r_num    AS
            (
                SELECT  vhb.offender_book_id
             ,        oci.comment_text
             ,        DENSE_RANK () OVER (OREDER BY oci.comment_text  desc)
                             AS r_num
             FROM    offender_case_identifiers oci
             ,         v_header_block           vhb
             WHERE   oci.offender_book_id      = vhb.offender_book_id
             AND         vhb.offender_id_display   = :ppid
             AND        oci.identifier_type           = 'ARN'
            )
            SELECT  offender_nook_id
            ,       comment_text
            FROM    got_r_num
            WHERE   r_num     > 1
        )
AND     identifier_type     = 'ARN'
;

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • need updated drivers Intel, motherboard, Dram and other

    First stop, I'm a big 75 years old grandfather with an observation of something that HP does not provide. But should!

    My wife and I bought of many HP laptops, desktops, tablets, etc. over the years. Right now, my concern applies to the Touchsmart from HP Envy 23se-d394. My wife has one and I also. We have all two laptops HP, etc, etc.

    Now, a driver update programs tells me that I need 14 software updates for Intel, motherboard, etc that I listed above. They want me to pay 40 dollars for the software update program.

    My question is why HP isn't a such FREE update program for us to use. We have spent countless dollars for HP products. So in my opinion, they should have a program update for us to use for FREE! Right?

    Your contribution will be appreciated. Thank you.

    Loy banks

    I suspect that the 'pilot program update' who wants $40 is not at HP, because as you said, HP should and provides necessary free updates.  This is the page for this PC drivers.

    http://support.HP.com/us-en/product/HP-envy-23-all-in-one-desktop-PC-series/5395609/model/5398988/drivers

    Click on the "Scan Now" button on this page.  It will then advise what updates are (free) coming from HP.

  • I get the error code 646 when trying to install 2 very important updates. Also pdf files and others are missing from the registry.

    RPDF files missing.never post private information such as numbers of mail or telephone!

    Ideas: pdf files are missing and error 646

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    during the installation of updates and some extensions files cannot be opened.  Also when you do e-mail or any continuous strike moving cursor then have to keep changing the typing.  Error 646 present during updates.

    Hey Jaynie Tatt

    Read and follow the information in the microsoft link below to fix your error code 646 using their fix - it or using the registry edit

    http://support.Microsoft.com/kb/2258121

    Walter, the time zone traveller

  • Windows update code error 00000646 KB960003 and others. did a scan and found that I have some corrupted files that cannot be fixed in the C:\windows\Logs\CBS\CBS. JOURNAL, I need help fixing problems

    error message 00000646. tried repair, cleaning of files and did the sfc/scannow

    Have you seen this sticky yet? -Online http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/6e716883-7af4-4a9f-8665-2f4dd57eee8d ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • windows error update_80246001 while updating c-media bus controllers and other equipment

    jams, mouse pads when you use the scroll arrows to the top?

    can't update windows update?

    Original title: windows error update_80246001 to update c-media bus & ports & other hardware controllers. My mousepad on laptop, the control arrows side bar when they are affected block the mouse?

    Hello

    You should not select updates for 3rd party material well Windows Update.

    For the 3rd group of hardware drivers, you can get them from the Web site of the computer manufacturer, or the manufacturer of the particular material.

    Microsoft is known for not having the latest drivers available for material from other manufacturers, Microsoft relies on the manufacturer to provide.

    See you soon.

  • 6.0.1: play store blocks - can not update Google Services to play and other applications (and phone is hot!)

    Hello

    I've updated to Android 6.0.1 (23.5.A.0.575) on my Z3 Compact (D5803) and I have a problem: I can't update the services Google Play or any application.

    What took place and what I've done:

    Step 1: Just after the update: random crashes

    Just after the update, notification Services play Google occurs as it is necessary to update. But when you tapoterez on it it opens stores Play, which closes immediately... If I open the game manually store, I have the same behavior (between 2 and 10 seconds before the accident). The accident leaves no message, it goes back only to "desktop".

    Step 2: Remove the cache, data, and updates

    I tried to delete the cache (step 1), data (step 2) and updates (3rd step) on Google Store with reboot, and each time had no effect on my problem: I have always had the same behavior.

    Step 3: Uninstall of updates of Google play Services

    I removed the updates of Google Services to play. Now, play store not crushed, but I can't update any app, I get the error "* App name * cannot be downloaded." Try again and if the problem persists, download help troubleshooting. (Error during extraction of the information from the server. ([DF-DLA-15]) »

    (or, in french: "Can't download the update of xxx, because an error has occurred (error when retrieving information from the server ([DF-DLA-15]).).")

    Could you help me please? How can I reinstall the Store and Services play?

    And another question: my phone is very hot! Is this normal with this update?

    Thank you.

    Hi Ze_Bast,

    You can try the following.

    1 uninstall the updates of Google Play Store

    2 clear data Google play Services

    3. clear the data from Google Services Framework

    4 restart handset

    5. try to access the Play store.

  • Envy 17 3010eg: upgrade to Windows 8 and update Bios: no switchable graphics and other problems

    Hello

    I'm of the Germany, but I'll do my best to write this in English.

    The product name and number: HP Envy 17 3010eg {information}

    Operating system: Windows 8 Pro 64-bit

    Drivers: everything up to date

     

    Long story short,

    I just wanted to upgrade the pre-installed Windows 7 Home Premium 64 - bit to the new Windows 8 Pro 64-bit.

    So I waited until the driver for Windows 8 support has been completed by HP.

    This month, I noticed that HP has released a graphic driver for Windows 8.

    Happy as I was I installed Windows 8 immediately via upgrade function.

    I installed all the missing drivers.

    * Update Bios to F.08*

    I noticed that I had to upgrade my Bios to version F.08 to install new graphics drivers. I did the upgrade and installation of the driver.

    BUT after the update to the version of the Bios the laptop only F.08 recognized the AMD graphics card. The integrated Intel HD 3000 graphics card had disappeared!

    Even after installing the new graphics driver, the Intel card is still missing in the 'Device Manager' of Windows 8.

    The battery life is now about 1 1/2 to 2 hours maximum because the laptop always uses the card AMD.

    So I looked in the 'new' Bios, but I have not found a way to change the graphics card. So I think that there is only a 'software' switch to do so.

    I have installed "AIDA64"and look under "Graphics".» The graphics card Intel HD 3000 has been mentioned as 'disabled'.

    Nice, but I have no idea how to turn it on again.

    So I re-installed Windows 8. This time, I did a completely clean install. With the same results.

    So, I switched to Windows 7, and there you go. Two graphics cards are displayed in "Device Manager" and the switchable graphics feature works perfectly (! even with the new version of the Bios F.08!).

    * Tested in Bios Version F.09*

    Yesterday, I noticed another Bios Update. This time in version F.09.

    So, I updated the Bios with Windows 7 installed.

    Everything went well (I thought!).

    Once, I've done a completely new installation of Windows 8 to take a peek, if Intel HD 3000 card will be recognized this time.

    BUT without success...

    So, I thought that the problem could only be Windows 8, because Windows 7 works perfectly.

    * Problems with Bios Version F.09*

    BUT then, I noticed a strange behaviour of my laptop:

    -proximity sensor no longer works

    -the keyboard backlight cannot be (DIS-) activated

    -the brightness of the backlight is half as usual

    -internal fans are going crazy-> they accelerate without reason (laptop is idle) and won't slow down until I do a re-boot

    * Version of the Bios downgraded to F.05*

    So, I spent to the version of the Bios to the older Version available: F05

    And I was a little shocked by the result.

    Windows 8 acknowledged the Intel HD 3000 graphics card again!

    The problem is the Bios!

    Then, I upgraded the version of Bios version to see which version of the cause of the problem:

    Œuvres F05

    Œuvres F.06

    F.08 does not work

    F.09 does not work

     

    So I decided to stay with the version F.06

    BUT to install the new Windows graphic 8 driver you need the version of Bios F.08 (min.).

    I installed the driver anyway...

    I found myself with a black screen... I had to reinstall Windows completely.

    Yet more long story short,

    I ended up using Windows 8 Pro 64 - bit with the graphics card AMD only.

    I also updated the Bios (back) to the version F.08 dispelled the problems with the version of the Bios F.09 I mentioned.

    So for the moment I am absolutely no idea what the problem might be.

    The support has not yet heard of these problems and I have not found any website which explains the same problem.

    Every posting, I found explains that the AMD card is not recognized by Windows 8 but Intel HD card.

    Someone else got the same problems?

    What do you think? Is it really a problem with the Bios?

    What can I do to solve the problem?

    for me the best driver are:

    http://leshcatlabs.NET/

    Works Perfekt (cards during execution of the F06 BIOS and a map when F08/09) and are updated often.

  • Miss me the update of windows and other important programs

    After having recently had a virus that took forever to get rid of, I found that miss me some useful programs. Like windows updater parts for Windows Firewall and other things. I was wondering if I could re put in disc manufacturing or would that erase my hard drive. Or if there is something I can do to get these back without wiping my hard drive and starting over. Thanks for all the answers

    Hello

    I suggest you run an antivirus scan using the Microsoft Safety Scanner to confirm that your computer is free from any infection by the virus. Please find the link below.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

     

    Note: The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

    Note: The Microsoft Safety Scanner ends 10 days after being downloaded. To restart a scan with the latest definitions of anti-malware, download and run the Microsoft Safety Scanner again.

    The Microsoft Safety Scanner is not a replacement for the use of antivirus software that offers continuous protection.

    Display the results.

  • menu shows update for photoshop 5, bright room 4, camera raw and other programs.  Cannot download. When I click on 'more', the screen shows me typing in the serial number on another screen, but the screen never comes to the top. my order number appear

    menu shows update for photoshop 5, bright room 4, camera raw and other programs.  Cannot download. When I click on 'more', the screen shows me typing in the serial number on another screen, but the screen never comes to the top. my order number appear in my adobe account.  so I don't see that Wizard download was interrupted.  After trying SEVERAL times to download updates, how do I do?

    update by downloading the files directly and then apply them: http://www.adobe.com/downloads/updates/

  • I update my windows 7 sp1 and etc., now boots very slow, also other application works too slow.sholud I unintall all updates?

    I update my windows 7 sp1 and etc., now boots very slow, also other application works too slow.sholud I unintall all updates?

    Hello

    1 are. what other applications you referring?

    I recommend you to uninstall Service Pack 1

    I suggest that you follow the steps mentioned below to refine the question causing third-party software (as applicable).

    Step 1:

    Test the issue in safe mode and check if the problem persists.

    Step 2:

    If your computer very well in safe mode functions, I would pt you your machine ├a State clean startup in order to eliminate conflicts of third party software.

    Note: Follow step 7 to restart your computer in normal mode

    See also: slow PC? Optimize your computer for maximum performance

  • I had the version 3.5.2 and Firefox updated to version 17. Is this good?

    Hello-
    I'm new to Firefox. I put it to update automatically. It has been updated to the latest version today, then I slept and watched, I noticed. I had the version 3.5.2 (I'm sure), but the latest version, it is just updated is version 17. Is this good? I'm used to the current version in the order but version 3.5.2 to 17? something go wrong?

    Yes, Firefox 17.0 is the current version. Firefox 17.0.1 will be released later today on Friday to correct some errors and regressions, so you can keep an eye on it.

  • After updating Firefox, most of my search engine options have changed, the United States, the United Kingdom and I am unable to get the USA those back. Of course, Google does not change.

    After updating Firefox, most of my available search engines top right changed the United States to the UK (except Google I'd rather not use) versions. I'm unable to retrieve Yahoo USA or Amazon or Ebay search engines.

    The sounds that you got the version of Firefox GB with the update.

    You can download en version and uninstall the current version of en - us and install the US version.

    Download a new copy of Firefox and save the file to the desktop.

    Do NOT remove the data personal when you uninstall your current version of Firefox, because all profile files will be deleted and you will also lose your personal data such as bookmarks and passwords from other versions of Firefox profiles.

    Your bookmarks and other profile data stored in the Firefox profile folder and will not be affected by a relocation, but make sure that you do not select delete data of a personal nature if you uninstall Firefox.

  • Bell (and other non U.S.) Atrix updates - release of v4.1.83?

    Hello team Motorola.

    I know that there was a previous discussion about the Atrix update for the version of Bell, but I would like to emphesize one the importance of support that do not receive the Bell phone buyers.

    In the last update published to users we AT & T:

    http://www.Motorola.com/staticfiles/support/us-en/mobile%20Phones/ATRIX_4G/us-en/documents/StaticFil...

    Better speed and a data connection has been inroduces and Skype very important (and other sound using apps) difficulty. I used Skype on iPhone to connect with friens and his family while I was abroad (usually on Wifi) but now I can no longer do it with my phone. The fact that there is a real problem that I did not is even more boring.

    In addition, e-mail messages do not appear in the Messages widget (which I love) bug has been fixed and I'd like to see on my phone.

    The Atrix Bell starts to become a very different phone than the AT & T Atrix and I would certainly not have such a difference, simply because I bought the phone at the Canada and not to the United States.

    Motorola recently said to have the best support for their devices after the separation of the mobility Department. I really hope to see this actually the case for all customers.

    Is anyone of Motorola can keep users in the loop?

    It will never be an update for the Atrix Bell? Is it is delayed due to the commit time? Is delayed by Bell or Motorola?

    Do you intend to release a big update after a few were published and validated in the AT & T model?


  • After the update and restart my computer was like a whole new vista version and the version of office business. All files and emails and contacts and other programs have disappeared!

    I did a system restore to run today.  He had updated 8 minutes before all this happened, but I couldn't say what update caused this.  It's important, so I guess that vista.  All of my Web site and software adobe software for forms and emails, files, photos, everything disappeared as if today, I bought the computer Office exccept was there, but empty. I have even been asked to set up an e-mail account.  I don't know how it happened with an update and cannot lose another day to such a waste of time. I work and am finishing my doctorate so the stability of my work being it is quite serious.  How this happened and how can I keep it doesn't happen. I backup to carbonite.com and have now checked, contacts, emails by the intermediary of today and all the files, but it's scarYYYYY!   I was never warned or the ability to restart or given in error messages.

    Hi Kelly Barr.

    Welcome to Microsoft answers forums!

    Are you referring to (files, emails, contacts and other programs) shortcuts on the desktop?

    When updates are installed on the computer it says system files, this process of service not Microsoft that are running in the background can conflict with updates and tour damage the system settings.

    This problem can also occur if system files are corrupt.

    Try the following in order to recover the desktop icons.

    Even though the desktop icons disappear, the programs are still installed on computer you can launch them.

    Method 1:

    Ø, right click on the desktop

    O select view

    Ø, click show the desktop icons

    Method 2: Click the Start button > select programs > verify if all the programs installed on the computer display > try to start or right click on the program and Select create a shortcut

    Check the updates that triggered this question go by the date.

    1. Click for Start > Control Panel > Classic view > Windows Update.

    2. along the top, click view update history.

    Before you install updates, follow the precautionary steps listed below.

    Step 1: Disable the security software on the taskbar

    Note: Activate security software once theupdates are installed.

    Step 2: Disconnect external devices like printer and scanner, except the mouse, keyboard, and internet connection.

    Step 3: The clean boot computer:- Perform a clean boot (check step 1 in the link)

    http://support.Microsoft.com/kb/929135 ---> how to solve a problem by performing a clean boot in Windows Vista or in Windows 7

    Important: n ' forget not to put the computer to a normal startup after you install updates. Follow step 7 in the link.

    Try to install updates via windows update or you can also download and install the updates manually by accessing the Microsoft Web site.

    Data backup on the computer

    You can use backup and Restore Center integrated in the operating system to back up data.
    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-and-restore-frequently-asked-questions

    Thanks and greetings
    Ajay K
    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • installation of updates from windows to windows 7 after 10/25/10 makes me lose all access to the internet (wireless and others)

    I have r530i samsung that is less than 8 weeks, after that 1 week, a new set of windows udates appeared which caused my Internet to lose. I spoke to my internet provider, between us, we confirmed there was nothing wrong with the connection or otherwise (I was able to access the internet from another PC using the same provider and user name) it was suggesteed downloads had done something for my wirless modem.

    I did a complete system restore and it worked just fine.

    a few weeks later, the same problem occurred after some updates of windows. Unfortunately the fault can be diagnosed because I can't access the internet? I did a full recharge of the system of 23/10/10, this has worked fine, windows then downloaded updates and my internet access has failed once again so I have disabled the automatic updates and everything seems fine.

    all connections work well, I can still see the home hub it won't let me access the help please

    Hello

    There are various reasons for internet connection doesn't work after installing the update of windows on the computer.

    First of all, I would say that you check the update is causing the problem.

    To see the updates are installed on your computer

     

    (a) open the updates installed by clicking the Start button, click Control Panel, clicking programs, and then r undeprograms and features, click view installed updates.

    Once you know the update's KB number then visit the Microsoft Download and put the number in the search box, download and install the update manually after placing the computer in a clean boot state.

    http://www.Microsoft.com/downloads/en/default.aspx

    To help resolve the error and other messages, you can start Windows Vista or Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    See the link below to learn more about how to clean boot.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Reset the computer to start as usual

    When you are finished troubleshooting, follow these steps to reset the computer to start as usual:

    (a) click Start, type msconfig in the search box and press ENTER.

    (b) If you are prompted for an administrator password or for confirmation, type your password or click on continue.

    (c) under the general tab, click the Normal startup option, and then click OK.

    (d) when you are prompted to restart the computer, click on restart.

    I hope this helps!

    Halima S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

Maybe you are looking for

  • wifi iPhone connectivity issues

    I have an iPhone 6 who has struggled to find and stay connected to wifi networks. If I'm right in a router, I am able to connect and use my phone without difficulty. However, as soon as I Dodge, it loses the connection and can not find the network ev

  • LTCC causes bad work at the G20-105 in standby mode

    HelloDoes anyone have a solution for LTCC dysfunction?I have the Qosmio power to the bottom of the screen the value after 5 minutes to be left blank. After another five minutes, a password is required to reactivate the desktop computer - eve of all k

  • Download avast free

    Buenosdias descargar avast gratis el deseo S2 Eva Plaza

  • Max EliteBook 840 G1 DisplayPort resolution

    HP Elitebook 840 G1 Product # F6A08UC #ABA Intel(r) HD Graphics Family Windows 7 Professional 16 GB OF RAM 1600 x 900 screen integrated Could someone tell me no doubt taken max resolution supported on the DisplayPort that laptop?  I make sure, that i

  • Portable Acrobat license for another OS?

    I bought a license of Acrobat for Mac.Since my Mac, will be the port Windows license for free?