PostgresSQL将多条子查询的统计结果作为查询结果

SELECT

    (SELECT COUNT (*) FROM d_info WHERE type = 0) AS common_total_count, --0普通总数

    (SELECT COUNT (*) FROM d_info WHERE type = 0 AND status = 0) AS common_offline_count, -- 00普通离线数量

    (SELECT COUNT (*) FROM d_info WHERE type = 0 AND status = 1) AS common_online_count, -- 01普通在线数量

    (SELECT COUNT (*) FROM d_info WHERE type = 1) AS special_total_count, --特殊总数量

    (SELECT COUNT (*) FROM d_info WHERE type = 1 AND status = 0) AS special_offline_count, -- 10特殊离线数量

    (SELECT COUNT (*) FROM d_info WHERE type = 1 AND status = 1) AS special_online_count; -- 11特殊在线数量

你可能感兴趣的:(PostgresSQL将多条子查询的统计结果作为查询结果)