SELECT 0 as status,COUNT(*) as statistic, 'name1' AS copy FROM table WHERE status=0 UNION ALL
SELECT 1 as status,COUNT(*) as statistic, 'name2' AS copy FROM table WHERE status=1 UNION ALL
SELECT 2 as status,COUNT(*) as statistic, 'name3' AS copy FROM table WHERE status=2 UNION ALL
SELECT 3 as status,COUNT(*) as statistic, 'name4' AS copy FROM table WHERE status=3 UNION ALL
SELECT 4 as status,COUNT(*) as statistic, 'name5' AS copy FROM table WHERE status=4

sql自定义列名字统计数据
最新推荐文章于 2023-03-27 09:46:22 发布
本文介绍了一种使用SQL进行数据状态统计的方法,通过联合查询不同状态的数据记录数,适用于需要快速获取多状态统计数据的场景。
965

被折叠的 条评论
为什么被折叠?



