SQL: Combine Select count(*) from multiple tables

后端 未结 8 651
迷失自我
迷失自我 2020-12-08 13:08

How do you combine multiple select count(*) from different table into one return?

I have a similar sitiuation as this post

but I want one return.

I t

8条回答
  •  感动是毒
    2020-12-08 14:10

    You can combine your counts like you were doing before, but then you could sum them all up a number of ways, one of which is shown below:

    SELECT SUM(A) 
    FROM
    (
        SELECT 1 AS A
        UNION ALL 
        SELECT 1 AS A
        UNION ALL
        SELECT 1 AS A
        UNION ALL
        SELECT 1 AS A
    ) AS B
    

提交回复
热议问题