SELECT COUNT(*) FROM Class t1unionSELECT COUNT(*) FROM Gym_Usage t2unionSELECT COUNT(*) FROM Badminton_Usage t3unionSELECT COUNT(*) FROM Pool_Usage t4;我目前只会这样写...但是这样不知道为什么只能出来三个结果,结果还不是按照写的顺序出来的。怎么样写才能让表格像下面这个样子呢....Class Class的总使用次数Gym Gym的总使用次数Badminton Pool 这样子列下来.....
2 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
select num,value from (
SELECT 1 as num,COUNT(*) as value FROM Class t1
union
SELECT 2,COUNT(*) FROM Gym_Usage t2
union
SELECT 3,COUNT(*) FROM Badminton_Usage t3
union
SELECT 4,COUNT(*) FROM Pool_Usage t4
) a
order by a.num
这样就搞定了顺序问题。
- 2 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消