当前位置:网站首页>Mysql使用union all统计多张表组合总数,并分别统计各表数量
Mysql使用union all统计多张表组合总数,并分别统计各表数量
2022-06-29 08:22:00 【蜗牛的小牛】
select count(distinct(vehicleId)) as ‘总数’,
count(distinct(case when flag = ‘t2’ then vehicleId end)) as ‘表2数量’
from
(
SELECT ‘t1’ as flag, cf.vehicle_id as vehicleId FROM ota_campaign_feedback cf WHERE cf.campaign_id = 1021612 GROUP BY cf.vehicle_id
union all
SELECT ‘t2’ as flag, c.vehicle_id as vehicleId FROM ota_vehicle_upgrade_check c WHERE c.campaign_id = 1021612 GROUP BY c.vehicle_id
) tt

利用count(case when …)条件统计,结合临时flag变量实现。
边栏推荐
- Huawei equipment is configured with small network WLAN basic services
- (pytorch进阶之路三)encoder self attention mask
- cokkie和session的区别
- 二手交易平台碳减排,有了评估标准
- 积分商城运营要如何做才能获取到利润
- 抽象类、接口
- How to recover data loss of USB flash disk memory card
- 图解SOC中的Timer(一):系统里有哪些Timer?
- verilog 等价操作符
- Déclaration de la variable Typescript - - assertion de type
猜你喜欢

New paid Tarot calculation source code (with building tutorial)

Compare homekit, MI family, and zhiting family cloud edition for what scene based experiences
![[redis] redis6 learning framework ideas and details](/img/64/836b1f8843a8eb91ff8da8c05ccd87.png)
[redis] redis6 learning framework ideas and details

July 2022 (advanced soft test) information system project manager certification enrollment Brochure

Dialogue | prospects and challenges of privacy computing in the digital age

sql server 用 administrator 权限运行吗?还是以普通用户运行呢?
Development tips - Image Resource Management

人民链鲍大伟:打破壁垒,建立全域数据治理共享及应用平台

laravel 8 实现 订单表按月份水平分表

Résumé des différentes séries (harmoniques, géométriques)
随机推荐
【无标题】
51 MCU interrupt and timer counter, based on Puzhong technology hc6800-esv2.0
Development tips - Image Resource Management
P6772 [noi2020] gourmet (matrix fast power)
Does the SQL server run with administrator privileges? Or run it as a normal user?
Unity C# 网络学习(十二)——Protobuf生成协议
2022年7月系统集成项目管理工程师认证招生简章
航芯开发板&调试器
Chengtong network disk imitation blue playing network disk source code with video tutorial
cokkie和session的区别
工作好多年,回忆人生--高中三年
Summary of various series (harmonic, geometric)
闭关修炼(二十五)基础web安全
PointNet/Pointnet++训练及测试
今年的网络安全“体检”你做了吗?
单例模式的理解
uniapp微信小程序报错 TypeError: Cannot read property ‘call‘ of undefined
Np5 formatted output (III)
Standard | China payment and clearing Association releases the first privacy computing financial specification
Oracle-子查询