MsSql task

Discussion in 'Databases' started by hoogoo, Dec 1, 2012.

  1. #1
    Hello everyone. I have a table. What should be the query(mssql) for this result?

    table:
    id name type number
    1 abc 1 100
    2 abc 0 20
    3 abb 1 200
    4 abb 0 150
    5 acc 1 120
    6 abc 1 200
    7 abc 0 10

    result:
    name number
    abc 270
    abb 50
    acc 120

    Here the solution is simple.

    1 abc 1 100
    2 abc 0 20
    6 abc 1 200
    7 abc 0 10
    // abc 100+200-20-10
    3 abb 1 200
    4 abb 0 150
    // abb 200-150
    5 acc 1 120
    // acc 120-0

    help me to write a query(mssql).
     
    hoogoo, Dec 1, 2012 IP
  2. concerto49

    concerto49 Greenhorn

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    10
    #2
    Hi, there would be a lot of queries that can derive those results? Perhaps it's better if you explain what you are trying to achieve and more information about what is happening?
     
    concerto49, Dec 5, 2012 IP