select count(1)from (select distinct unique_id_station from d_wx_expansion_oarea2023 dweo where 1 = 1 and unique_id_station is not null and province_name ='河北省'and month_id ='202212' ) as a union all select count(1) from d_wx_expansion_oarea2023 where 1 = 1 and province_name ='河北省'and city_name ='邯郸市'and month_id ='202212' union all select count(1) from d_wx_expansion_oarea2023 where 1 = 1 and province_name ='河北省'and city_name ='邯郸市'and month_id ='202212' and is_pdcp_busy_week =1 union all select count(1)from(select distinct unique_id_station from d_wx_expansion_oarea2023 where 1 = 1 and province_name ='河北省' and city_name ='邯郸市'and month_id ='202212' and is_pdcp_busy_week =1 and unique_id_station is not null) as aaa将四个sql语句合成一个
时间: 2024-03-29 18:41:16 浏览: 147
select count()和select count(1)的区别和执行方式讲解
SELECT
(SELECT COUNT(DISTINCT unique_id_station) FROM d_wx_expansion_oarea2023 WHERE province_name = '河北省' AND month_id = '202212' AND unique_id_station IS NOT NULL) AS cnt1,
(SELECT COUNT(*) FROM d_wx_expansion_oarea2023 WHERE province_name = '河北省' AND city_name = '邯郸市' AND month_id = '202212') AS cnt2,
(SELECT COUNT(*) FROM d_wx_expansion_oarea2023 WHERE province_name = '河北省' AND city_name = '邯郸市' AND month_id = '202212' AND is_pdcp_busy_week = 1) AS cnt3,
(SELECT COUNT(DISTINCT unique_id_station) FROM d_wx_expansion_oarea2023 WHERE province_name = '河北省' AND city_name = '邯郸市' AND month_id = '202212' AND is_pdcp_busy_week = 1 AND unique_id_station IS NOT NULL) AS cnt4;
阅读全文