Help! Can this be done in one statement?

po_line_tbl
po_id(PK) line_nbr(PK) qty
001 1 250
001 2 100
po_line_distrib_tbl
po_id(PK) line_nbr(PK) distrib_nbr(PK) qty
001 1 1 75
001 1 2 75
001 1 3 75
001 2 1 100
There's a one to many relationship between the two tables. in the distrib table, for line_nbr:1, sched_nbr:3 the quantity needs to be changed to 100. The update needs to check the sum of the quantity on the distrib table line_nbr for any given po_id. So:
select line_nbr, sum(qty) from po_line_distrib where po_id = '001' group_by line_nbr
1 225
2 100
If that quantity doesn't equal the quantity in the line table for that given line. the max distrib_line needs to be updated with the difference in the quantity.
So line_nbr:1, distrib_nbr_3 would need to be changed to 100.
Thanks all!!

Hi!
You can try this:
update po_line_distrib_tbl A
set A.qty = A.qty + (select (select D.qty
                             from  po_line_tbl D
                             where D.po_id = A.po_id
                             and   D.line_nbr = A.line_nbr) -
                         (select sum(C.qty)
                             from  po_line_distrib_tbl C
                             where A.po_id = C.po_id
                             and   A.line_nbr = C.line_nbr)
               from dual)
where A.distrib_nbr = (select max(B.distrib_nbr)
                       from PO_LINE_DISTRIB_TBL B
                       where A.po_id = B.po_id
                       and  A.line_nbr = B.line_nbr)Thanks,
Rico

Similar Messages

  • Can this be done with one update statement?

    update test_tbl
    set clob_col = replace(clob_col,str1,'')
    where str1 is not null
    and update_flag = 'F';
    update test_tbl
    set clob_col = replace(clob_col,str2,'')
    where str2 is not null
    and update_flag = 'F';
    update test_tbl
    set clob_col = replace(clob_col,str3,'')
    where str3 is not null
    and update_flag = 'F';
    update test_tbl
    set clob_col = replace(clob_col,str4,'')
    where str4 is not null
    and update_flag = 'F';
    commit;

    Hi,
    As stated in previous reply:
    REPLACE ( char , search_string, replacement_string)
    If search_string is null then char (the original) string will be returned.
    This means you do not have to check on the search_string being null.
    You may want to add to the where clause is any of the str1 .. str4 is not null.
    update test_tbl
    set
    clob_col = replace(
                        replace(
                                replace(
                                        replace(clob_col
                                        ,str1,'')
                               ,str2,'')
                      ,str3,'')
                ,str1,'')
    where
      update_flag = 'F'
      and str1 || str2 || str3 || str4       is not null    -- select only one of these
      and COALESCE (str1, str2, str3, str4 ) is not null    -- select only one of these
    commit;Regards,
    Peter

  • I would like to transfer the balance from one Apple ID to another how can this be done??

    I want to transfer the account ballance from my account to my son's. I unintentionally redeemed one of his gift cards to my account. how can this be done?

    Sorry, but balances can't be transferred from one iTunes Store account to another. You'll either have to make his purchases through your account, or buy another prepaid card and redeem that in his account.
    BTW, for future questions, this forum is for questions from those managing sites on iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. You'll be most likely to get help if you ask in the general iTunes forums.
    Regards.

  • Since Windows 2003 Services ending we moving Sharepoint Services 3.0 to Windows 2008R2, Any help how can this be done ?

    Since Windows 2003 Services ending we moving Sharepoint Services 3.0 to Windows 2008R2,
    Any help how can this be done ?
    We have 1 Server and single Farm.
    I have build New 2008 R2 Server and planning to restore Backup taken from Old server to this new server. Will this work ?
    Which version of Sharepoint should i install on Windows 2008 R2 server , i run sharepoint.exe downloaded but it throws error

    Sorry for late reply.
    Your next step is, create a new web application and deattach the content DB from new web application. You need to attach existing CDB to that web app.
    Here is some links for your ref (unfortunately this is for 2010 but it same steps should work in WSS as well)
    http://nikpatel.net/2009/03/11/step-by-step-process-move-site-collections-from-one-content-database-to-another/
    http://www.sharepointpitstop.com/2012/06/attachdetach-sharepoint-webapp-contentdb.html
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How do I set up two separate iTunes accounts on one MacBook Pro in order to manage the wife's iPhone and my iPhone? Can this be done?

    How do I set up two separate iTunes accounts on one MacBook Pro in order to manage the wife's iPhone and my iPhone (with separate info on each of course) ? Can this be done? A little step by step would be greatly appreciated; just short step by step though, I can follow fairly well.
    Kindest Regards,
    Phil T.

    You would each need to use your own user account on the Mac, you can do this at system preferences > users & groups.

  • I need to read data from a text file and display it in a datagrid.how can this be done..please help

    hey ppl
    i have a datagrid in my form.i need to read input(fields..sort of a database) from a text file and display its contents in the datagrid.
    how can this  be done.. and also after every few seconds reading event should be re executed.. and that the contents of the datagrid will keep changing as per the changes in the file...
    please help as this is urgent and important.. if possible please provide me with an example code as i am completely new to flex... 
    thanks.....  

    It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
    [http://java.sun.com/docs/books/tutorial/essential/io/]
    *Unless you write a bunch of JNI code to replicate what the java.io classes are doing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I have just got a new computer and I want to transfer Adobe Acrobat to my new one can this be done ?

    I have just got a new computer and I want to transfer Adobe Acrobat to my new one can this be done ?

    Hi Ianpce,
    You need to download and install Adobe Acrobat on the new machine to use it.
    You can use the same subscription or the serial number to activate the product.
    Thanks

  • I have numbers on mac mini and need to email as an attachment  one sheet instead of the 30. Can this be done

    Can anyone help please. I have just downloads the numbers app. I have a very large document of which i need to send a separate sheet each week as an attachment via email. Can this be done?. Sadly, I am used to Neo and that was rather easy to do.   I could not find the answer for excell either!  Surely, saving each sheet separately is not the only answer. 

    File > Print
    set the print range "From "  = 1, "To" = 1 in the print dialog, then
    click the "PDF" button the bottom left and select "Mail PDF"
    If you must send a Numbers document, then I think I would copy the germane content into a new document and save as the current month (or week), then attach that document.

  • I want to make a CD that is NOT in alphabetical order, not in artist alphabetical order and not in album alphabetical order... I want to make it the order I want.  Can this be done? How?  thanks in advance for all your help.  Mona

    I want to make a CD that is NOT in alphabetical order, not in artist alphabetical order and not in album alphabetical order... I want to make it the order I want.  Can this be done? How?  thanks in advance for all your help.  Mona

    cjam732 wrote:
    Ed - by sequence of numbers, are you talking about the rectangle with the arrow that sorts by track number?  I've tried to follow your directions to Mona but my playlist still gets burned to CD in alpha order.  driving me crazy.  any other suggestions?   thanks, Chris
    Chris, The sequence number is the first column of numbers, to the left of the Name column.  It always goes 1, 2,3  etc.  It is not the same as the Track Number, which has its own column.
    As a precaution before burning, make sure that Shuffle is tunred off, and that you right-click the playlist name and choose 'Copy to Play Order"  (although technically they should not affect the burn).

  • I I am trying to create a collage with 4-6 photo so I can print them on one sheet.   Can this be done in IPHOTO?

    I am trying to create a collage with 4-6 photo so I can print them on one sheet.   Can this be done in IPHOTO?

    Here are 3 options for future reference:
    1. With the setup you've described, apply a Match Move behavior to  the text and make the rectangle the source. Change the Transform parameter to Mimic source.  This way you can still adjust the text postion as needed, but the rectangle will drive the animation.
    2. Use a group to do the animation.  Put both your rectangle and text in the same group and animate the group's postion.
    3. Use the Link behavior.
    Each of these has it's advantages depending on what you need.

  • Hi. I have bought both Adobe XI Pro and standard and downloaded only one of them yet. How do i proced to download the other? Can this be done without install or perticipate within Creative Cloud, only by using username and PW?

    Hi.
    I have bought both Adobe XI Pro and standard and downloaded only one of them yet.
    How do i proced to download the other?
    Can this be done without install or perticipate within Creative Cloud, only by using username and PW?

    I assume you have the S/Ns. The download is at http://helpx.adobe.com/acrobat/kb/acrobat-downloads.html. Be sure to backup the download to CD or backup HD for future use.

  • I am using referenced images, saved on an external hard drive. It would be most helpful to transfer the new captions (version name) to the referenced images which still have the camera code on them. How can this be done? Thanks so much!

    I am using referenced images, saved on an external hard drive. It would be most helpful to transfer the new captions (version name) to the referenced images which still have the camera code on them. How can this be done? Thanks so much!

    You're question is hard to follow. Are you looking to rename your master files to the version name? Or are you looking to do something with IPTC caption field and the masters?

  • Can this be done?

    I am formatting a form in Adobe Acrobat Pro 9. One of my fields is for a credit card number. I have set up a "Special" Arbitrary Mask to the format and limit of numbers that can be entered.
    What I would like to do it Mask some of the numbers as they are entered. I entered the Arbitrary Mask as 9999-****-**99-9999. The problem is that this set up is causing the entry to skip the ***. My concern then is that the person entering the data will not realize this skip and not provide the correct ending numbers.
    What I would like to happen is that the person entering the data will type the complete 16 digit number and the system will MASK the numbers I designate with an **.
    Can this be done?
    Thanks in advance for any assistance.
    Kathy

    Hopefully I'm not breaking any posting rules by saying "I think I love you!"
    My functional desires always exceed my knowledge level so I want what I don't know how to create. Your script totally worked and I would never have figured that out on my own. I want to learn what you do very badly.
    We are masking the numbers for security reasons. We know the numbers being masked but we don't want to store the full number in our records. 
    Thank you so much for your help, What kind of experience do you have with Access 2007 or 2010?
    Kathy

  • I have an iPod touch 4g that is jail broken and I would like to have it back to normal how can this be done?

    Can some one help me with my issue I have an iPod touch 4g that is jail broken and I would like to have it back to normal how can this be done?

    No one here can help you with that, check Google.
    If the baseband has been changed and you are trying to put the phone back to a condition to unlock it be aware you may not be able to accomplish this.

  • Can this be done with css rollovers?

    Hi,
       I'm using Dreamweaver CS4 on a Windows PC. I understand the basics of css rollovers where you change the background image position up or down but the text used will still end up being a common font that will suit every pc. What I'd like to do is use an uncommon font in my navigation bar. I made an image in photoshop that had two versions of a word like home for example one on top of the other like you would for a css rollover but once I created a link I had the link color border around the image, so it didn't work. Here is a link to a website that is similar to what I'm trying to do http://www.inksmithtattoo.com/. Look at the navigation, can this be done using css rollovers? If not how do you think it was done? Is there a way to use uncommon fonts in a navigation bar? I even did some research on using Dreamweavers hotspot function but found that there were issues in using it for navigation. I'm getting pretty familar with Dreamweaver but I'm not that good at coding so if anyone does have any ideas please include some keywords that I can google and read more about what your trying to say, links to the info would be even better but I realize that if your as busy as I am you can't take that kind of time.
    Any ideas or help will be greatly appreciated.
    Thank you to all,  dluthier

    That site is using images only. It is not a text based link:
    here is the css they are using:
    #navAbout a {
    -moz-background-clip:border;
    -moz-background-inline-policy:continuous;
    -moz-background-origin:padding;
    background:transparent url(../_img/navAbout-Home.gif) no-repeat scroll 0 0;
    left:473px;
    top:318px;
    As you can see it is an image only. See the attachment with this post. Also since it is a background image it won't show up if you right click on the so seemed text
    Please install firebug or webdeveloper plugin if on Firefox and you will be able to inspect the elements and know what exactly they are.
    Hope it helps
    Regards,
    Vinay

Maybe you are looking for

  • IPod Classic 80-gig won't transfer purchases to iTunes Library, nor will it sync. Please help!

         My iPod Classic 80gb will not transfer purchases to my iTunes library. When I click the "Transfer Purchase" button, it says it's working, but then I get a pop-up which reads 'Attempting to copy the disk "OS" failed. An unknown error occurred (-6

  • How many songs can I add to a iDVD slideshow

    I am putting topgether a long slideshow in iDVD and would like to use several musical items, rather than one replaying.  Is there any way to do this?

  • Cant get it to publish

    Hello! My name is Richard and I'm using Dreamwear MX2004, with IIS on MS XP Pro. Used it awhile back and everything went well. Published the site, no problem. Since then, I deleted everything I had done (cause it was trash) and started over. This was

  • Creating slideshow/gallery in catalyst

    I am a designer (non-web) and I really want to utilize catalyst for a portfolio site. I was wondering if there was an easy way to create a "proffesional" looking gallery of portfolio images. I am somewhat familiar with catalyst, just stuck on this on

  • Why can't I copy and paste a document in an online class discussion?

    I just updated Firefox. I am currently participating in an online college class and for some reason cannot paste a report I have typed in word on the discussion page of the class? I haven't had any trouble before this. This document needs to be done