Any Sql Solution for this?

Hi guys,
How can I update rows which total upto the number of dollars the user enters.
Ex: I have the following rows in the table
Col1 Col2 Col3 Col4
1------10------A
2-------3------B
3-------7------C
4------20------D
5-------5------E
6-------5------F
I have a procedure which takes a user input (say 23). Now I need to update Col4 with EXT for all those rows which total to 23. So the result should look like
Col1---Col2---Col3----Col4
1------10------A------EXT
2-------3------B------EXT
3-------7------C
4------20------D
5-------5------E------EXT
6-------5------F------EXT
Had to insert dashes for formatting purposes...
Any solutions will be appreciated.
Thanks
John

Hi John,
Well, that's a very strange way to do it but if you must, there's no problem saying:
UPDATE TABLE SET Col4 = 'EXT' WHERE Col1 + Col2 + Col3 = 23;
However, I suspect you intend that the user may enter any number of values. If this is the case, you'd be much better off (in the relational world, anyway) entering a new row for each of the new values, viz:
User, Date, Input
1, 01/01/2003, 10
1, 13/01/2003, 5
1, 15/01/2003, 8
2, 19/01/2003, 20
2, 10/02/2003, 3
3, 4/01/2003, 21
Now you can say:
SELECT SUM (Input) Total, COUNT (Input) NrInputs FROM TABLE GROUP BY User HAVING SUM (Input) = 23;
... which works much better and will work for any number of columns. You don't even need the date column unless, for some reason, you need to order the input.
d.

Similar Messages

  • Any better solution for this ?

    public static void main (String args [])
         for (int row = 1; row <= 5; row++)
              for (int col1 = 4; col1 >= row; col1--)
                   System.out.print(" ");
              for (int col2 = row*2; col2 > 1; col2--)
                   System.out.print("*");
              System.out.println();
         for (int row = 1; row <= 4; row++)
              for (int col1 = 1; col1 <= row; col1++)
                   System.out.print(" ");
              for (int col2 = 4; col2 >= row; col2--)
                   System.out.print("*");
              for (int col3 = row; col3 < 4; col3++)
                   System.out.print("*");
              System.out.println();
    }I'm trying to make this:
    I think that my solution is too long. any shorter solution?
    TQ

    It IS hardwired to produce that figure and only that figure.
    What if they asked you to redo it with fewer or more rows of stars?
    You did a "bad" thing: you hardwired your loop sizes. Something like "i <= 4" is called a "magic number", because someone reading your code would have no idea where the 4 came from.
    You also have 4 appear in several places. That violates the Don't Repeat Yourself rule. If you have to change it, and forget one of the spots, your code is wrong.
    You can help both situations by defining a well-named constant and using that for the loop upper limit:
    public class DiamondsAreAGirlsBestFriend
       public static final int DIAMOND_SIZE = 4;
       public static void main(String [] args)
          for (int row = 0; row <= DIAMOND_SIZE; ++row)
          // and so on
    }Also, better to put this into a method that would take in a diamond size value and return a String. Then it's general.
    None of this is very important for this trivial problem, but they might be worth remembering when you start writing more complex programs.
    %

  • Any help/solution for this please??

    You'll need to subscribe to watch this channel.
    I see it looks like a lot of people may be having this issue, i now cannot view any of the BT Sports channels beit in HD or normal.
    Black screen telling me i have to subscribe.
    Went on live chat 87 in the queue, by the time i got down to number 1 (30plus minutes) it said there was no available advisors.
    I was also on the phone the same length of time, only for it to go dead, this has happened 3 times whilst trying to phone BT.
    Any help please, thanks

    I can view it all via the apps and the online player, just not via my BT Vision box.

  • Is there any alternative logic for this issue

    Hello all ,
    I have a  program which is executed as a background job for every 15 minutes . Now my requirement is If this batch job is successfully finished, i have to capture that time and date at which the batch job is successfully finished and update the corresponding time and date in a ZTABLE .
    In order to achieve this , i have created a separate program which will also be running in background.in this program , using the table TBTCO, i m getting the last date and  last time at which the batch job is successfully finished and modifying the ZTABLE accordingly
    Is there any alternate solution for this ?
    thanks&regards,
    G.Pavan

    Hi gpavansap,
    When you define background job in SM36, your first step should be the program which you have scheduled now.
    Create a second step in the same job with another program which would just update system date and time to the ZTABLE. No need to read TBTCO and all.
    The second step would immediately execute as soon as the first step ended successfully.
    If you don't want to create a separate program. you can have a check-box "Update ZTable Only" in the selection screen of the first program itself. If this check-box is selected, the program should only update ZTABLE and do nothing else. Create a variant of your selection screen with this check-box selected and schedule this variant as "Second Step" of your back-ground job.
    Regards
    Suresh

  • After update my iPad 2 with IOS 6.0.1 the botton mute and sound + doesn't work...any solution for this??? Thanks

    After update my iPad 2 with IOS 6.0.1 the botton mute and sound + doesn't work...any solution for this??? Thanks

    There are numerous reports of this issue happening on iPhones. It may be a glitch that will need a new update. Some find that a full shut-down and restart fixes that problem, but not always.

  • I bought iPhone 3GS(Used) recently and updated ios 6.1.3 my iPhone is taking blurry Pictures through basic default Cam app.Can anybody please let me know any solution for this?

    I bought iPhone 3GS(Used) recently and updated ios 6.1.3 my iPhone is taking blurry Pictures through basic default Cam app.Can anybody please let me know any solution for this?

    Basic troubleshooting steps right out of the user guide are restart, reset, restore from backup, restore as new.  If you've been through ALL the steps and you still have the problem, then you'll need to bring your phone to Apple for evaluation.

  • I bought my iphone 5 in Houston Texas May 15 2013 IMEI Nr. 013428009645399.The problem is that in the Greece the country which I live the 4G is not working.If you have any solution for this problem pls. let me know.My email is philcoueth@yahoo.gr Thank yo

    I bought my iphone 5 in Houston on May 15 2013.
    IMEI 013428009645399.The problem I have is that in the country
    which I live GREECE the 4G is
    not working.Please if you have any solution for this
    problem let me know.My email is [email protected]
    Thanking you in advance
    Philip Couridis

    iPhones purchased in the US are NOT guaranteed to work with 4G bands outside of North America.
    For what crazy reason did you purchase an iPhone in the US if you live in Greece?  If your phone needs servicing, it will have to be brought back to the US.  You cannot get that phone serviced in Greece.

  • I just bought a new iMac and am having troubles downloading creative cloud installer.  Its coming up with error 214 - I can't find any solutions for this.  Can anyone help me?  Im on mac OS 10.9.4

    I just bought a new iMac and am having troubles downloading creative cloud installer.  Its coming up with error 214 - I can't find any solutions for this.  Can anyone help me?  Im on mac OS 10.9.4

    Meg81 error 214 indicates a download data validation error.  This means that the update you downloaded became corrupted likely during the download process.  I would recommend utilizing the suggestions listed in Error downloading Creative Cloud applications - http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html to attempt to improve the stability of your Internet connection.
    You can also find information on how to review your download logs which may provide additional information regarding the failure of the download.

  • When i tap "update" on an app, or try and download a new app i get the loading wheel for around a second then it goes back to showing "update" and does nothing.  Any solutions for this?

    When i tap "update" on an app, or try and download a new app i get the loading wheel for around a second then it goes back to showing "update" and does nothing.  Any solutions for this?  This is relevant to an iPhone 5S running iOS 8

    If you're really running iOS 8, you should be posting in the Developer's Forum, as you well know since you signed an NDA when you signed up for the Developer's program.

  • I accidently removed my clash of king game from Game Center, but my profile is still there and i want it back. Any solution for this situation?

    I Accodently removed mu Clash of King game from Game center, but my profile is still there, I want it back.Any solution for this situation?

    Install the game again.

  • I have a problem openning my Itune home, I'm getting unknown error 0x80090308, any body has a solution for this problem

    I have a problem openning my Itune home, I'm getting unknown error 0x80090308, any body has a solution for this problem

    hi marco
    I found the problem. Do you have other wi-fi (w-lan) like repeater or tv-transmitter or d-link etc. if yes, please disconnect them once and try again after restarting the time-capsule resp. change the channel if you can to another one. then it should work again.
    @ home i have a tv-transmitter via wi-fi and indeed, i changed the channel from 1 to 6 or something like that, then the iphone worked again.

  • M having a macbook, after successful shut down it is booting up automatically is there any solution for this?

    M having a macbook, after every successful shut down it is booting up automatically. Is there any solution for this?

    There isn't a separate app icon for Facetime for the iPhone like there is for the iPad and iPod Touch.  Facetime is built into the iPhone's iOS.
    Here a refresher on how it works: 
    iOS:  Using Facetime, http://support.apple.com/kb/ht4319

  • Buy second hand iPhone ........... i have apple id of previous owner but no password ... now the phone is in icloud activation mode . any solution for this.

    i buy second hand iPhone from Olx ........... i have apple id of previous owner but no password ...
    now the phone is in icloud activation mode . any solution for this.
    totally wastage of money , if there is no solution .
    for security purpose this icloud activation is Good ............

    Read this
    http://support.apple.com/kb/TS4515?viewlocale=en_US&locale=en_US

  • TS4436 hi, when zooming in to capture still images, the image is really blurred and out of focus. is this a hardware issue and is there any solution for this?? or is my device faulty?

    hi, when zooming in to capture still images, the image is really blurred and out of focus. is this a hardware issue and is there any solution for this?? or is my device faulty?

    If you are using the iPhone camera zoom then remember that this is a digital zoom not an optical zoom. The zoomed in area will have fewer pixels and not appear as clear. The more you zoom the worse it gets. It's like cropping a picture after it has been taken.

  • I am having an iPad 4. I am not getting alerts while receiving any call in my ipad. Is there any solution for this?

    I am having an iPad 4. I am not getting alerts while receiving any call in my ipad. Is there any solution for this?

    Check your settings
    Settings>Notifications>FaceTime/Message>Alert Style

Maybe you are looking for