How to combine two sql queries into one

后端 未结 4 1393
南旧
南旧 2021-01-05 15:36

How can I combine these two SQL statements?

SELECT SUM(hits01 + hits02 + hits03 + hits04 + hits05 + hits06 + hits07 + hits08 + hits09) AS \'AEROwiz\'
FROM tb         


        
4条回答
  •  北海茫月
    2021-01-05 16:18

    Use a UNION query - just stuff "UNION" between the two queries:

    SELECT SUM(...) AS AEROWiz
    FROM ...
    
    UNION
    
    SELECT SUM(...) AS AEROWiz
    FROM ...
    

    update

    wrap the union in yet another query:

    SELECT SUM(AEROWiz)
    FROM (
        .... unioned queries here
    ) AS child
    

提交回复
热议问题