Evgeniy Kleban Evgeniy Kleban - 1 year ago 126
SQL Question

Sum specific row values in SQL

I have table with many columns, i interested in column "a", column "b" and column "val". What i need is, to create query, when a is equal to specific int (lets say a=1) and b also equal to specific int (b=1). For every row that match that criteria i want to sum values, that indicated in "val" column. How to create that query?

Answer Source

You should use a group by clause

    , b
    , sum(val)
group by
    , b
    a = 1
    and b = 1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download