In-CASE you need to SUM...

  • Comments posted to this topic are about the item In-CASE you need to SUM...

    Ben

    ^ Thats me!

    ----------------------------------------
    01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
    ----------------------------------------

  • Good question today, thank you.

  • Nice. First I just summed everything, but then I realized this would be too easy 🙂

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Nice question, but the title is missleading. It isn't about the case and sum, but the union without all keyword.

  • palotaiarpad (7/11/2011)


    Nice question, but the title is missleading.

    .

    I guess that was the point 🙂

    Putting UNION in the title would give the solution away.

    Questions like these remind us that details are important, especially when you are debugging code from someone else.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • This was removed by the editor as SPAM

  • thanks 🙂

    My team leader got it wrong.. 😀

    Ben

    ^ Thats me!

    ----------------------------------------
    01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
    ----------------------------------------

  • Nice! 🙂 I got it as i have been playing around with Unions lately. But i could not undertand what makes a difference when it is executed on SQL Server 2008?

    Regards,

    Mazhar Karimi

  • But i could not undertand what makes a difference when it is executed on SQL Server 2008?

    It shouldn't. I guess the version is specified because in the past there were troubles with questions where the version did matter (and people lost points et cetera).

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I dont have SQL 2008 here so couldn't test to be 100% sure before posting.

    should work exactly the same, but I'm not one to release untested code 😉

    Ben

    ^ Thats me!

    ----------------------------------------
    01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
    ----------------------------------------

  • Great question.

    I first thought 47, but the 18 in the answers made me hesitate, then the calculation for 18 simply led me back to the insert statement and the UNION (ALL)... Eureka! 🙂

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • nice to see people properly dry running it! when I was at college 5/6 years ago the teachers were allways banging on about dry running code and none of the other students could be bothered to work out how to do it.

    I find sometimes that it is very easy to get complacent with code - I often type code and hit run to see if it errors rather than actually looking at what I type. when it comes to simple programs that's fine but when it comes to complex logic etc being able to dry run your code in your head is a very important skill to have. When writing code around finances especially - bothering to think logically about your program before you just go ahead and compile it can mean the difference between everything running fine and your company getting investigated over tax problems!

    Ben

    ^ Thats me!

    ----------------------------------------
    01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
    ----------------------------------------

  • Thanks. A nice "real-world" question for us developers.

  • Great UNION plays a big part....

  • Nice question thanks 🙂

Viewing 15 posts - 1 through 15 (of 45 total)

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