1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

can i wrire a query which sum up more than 2 columns in a single table?

Discussion in 'SQL - Questions and Answers' started by kajal, Mar 4, 2007.

  1. kajal New Member

    Dialect: MS SQL
  2. Dimitar Guest

    Dialect: SQL 92
    Doesn't this work:
    SQL:

    select sum(col1+col2+col3) from theTable

    ?
    And I can resist posting a variant using unions:
    SQL:

    select sum(col) from (select sum(c1) as col from t union all select sum(c2) as col from t union all select sum(c3) from t) as theTable


    Please, tell us if this helps.
  3. meera Guest

    Dialect: MySQL
    SQL:

    SELECT sum(col1)+sum(col2)+sum(col3) FROM table
  4. Unregistered Guest

Share This Page