Home Forums Programming General Need Help on SQL query script on sum RE: Need Help on SQL query script on sum

  • Welcome to this forum,

    I really hope that we can help you, but there's something that I can't understand. You say: "The flag indicator will tag with 'Y' if 1 unit >= 50"

    Do you mean that only when there's a single unit? or when any unit is >= 50?

    To get better help, you should give us DDL and sample data in a consumable format. Since you're new to this forum and SQL, I'll do it for you, but I recommend you to read the article linked in my signature.

    CREATE TABLE #Test (

    Unit_ID int,

    Value int)

    INSERT #Test VALUES

    (1, 20),

    (1, 30),

    (1, 20),

    (1, 30),

    (1, 10),

    (2, 51),

    (3, 50),

    (4, 20),

    (4, 30),

    (4, 10),

    (4, 5),

    (4, 50),

    (5, 5),

    (5, 50),

    (6, 5),

    (6, 3),

    (6, 50),

    (7, 35),

    (7, 4)

    SELECT *

    FROM #Test

    DROP TABLE #Test

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2