Summing Problem.

  • Hi All,

    Have been racking my brains to come up with a solution to the following problem but as yet with no luck. Hope you guys can help me out here.

    I need to find a particular date from a group of transactions when the sum of those transactions exceeds £100. There could be maximum of about 10 transactions but at any stage this could top the £100 level.

    So for example:-

    Account TransAmount TransDate

    1 75.00 01/11/2011

    1 50.00 02/11/2011

    1 100.00 03/11/2011

    So I'd like to return 02/11/2011 as the sum of the transactions exceeds £100 at this point.

    Any ideas would be much appreciated.

    Thanks,

    Gary

  • Can you please post the DDL for this table.

    Also, to confirm... You would like to return the date for a specific account when that account's transactions have exceeded $100 (sorry, don't know where the pound is)?

    Thanks,

    Jared

    Jared
    CE - Microsoft

  • Read this article by Jeff Moden, and its sample T-SQL .. it may be the answer to your question

    http://qa.sqlservercentral.com/articles/T-SQL/68467/

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • bitbucket-25253 (10/25/2011)


    Read this article by Jeff Moden, and its sample T-SQL .. it may be the answer to your question

    http://qa.sqlservercentral.com/articles/T-SQL/68467/

    Many thanks guys.

    I have started reading the article and need a drink! I can see though that it's exactly what I need.

    Thanks,

    Gary

  • WardyWonderland (10/25/2011)


    bitbucket-25253 (10/25/2011)


    Read this article by Jeff Moden, and its sample T-SQL .. it may be the answer to your question

    http://qa.sqlservercentral.com/articles/T-SQL/68467/

    Many thanks guys.

    I have started reading the article and need a drink! I can see though that it's exactly what I need.

    Thanks,

    Gary

    It is a great article, and should show you all of the available methods. For the pseudo-cursor/quirky update keep in mind his warning, though, and weigh those risks for your situation. The warning is there for a reason and you will bear the consequences of any problems or just plain arguments against using a pseudo-cursor/quirky update. Make sure you understand all requirements in the article before attempting. If you are the least bit unsure, use an RBAR method. Also, test, test, test. Then test some more.

    Jared

    Jared
    CE - Microsoft

  • jared-709193 (10/25/2011)


    WardyWonderland (10/25/2011)


    bitbucket-25253 (10/25/2011)


    Read this article by Jeff Moden, and its sample T-SQL .. it may be the answer to your question

    http://qa.sqlservercentral.com/articles/T-SQL/68467/

    Many thanks guys.

    I have started reading the article and need a drink! I can see though that it's exactly what I need.

    Thanks,

    Gary

    It is a great article, and should show you all of the available methods. For the pseudo-cursor/quirky update keep in mind his warning, though, and weigh those risks for your situation. The warning is there for a reason and you will bear the consequences of any problems or just plain arguments against using a pseudo-cursor/quirky update. Make sure you understand all requirements in the article before attempting. If you are the least bit unsure, use an RBAR method. Also, test, test, test. Then test some more.

    Jared

    I don't disagree with Jared on this, but if you run into trouble, or just want a second set of eyes, post up some consumable sample data and your query and we'll help you lock it down. See the first link in my signature if you need assistance with understanding what we mean by consumable.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Greatly appreciated guys.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply