Table1
Id name status type
1 a start 1
2 b end 2
3 a start 1
4 b end 2
5 a start 1
6 b end 2
7 a start 1
8 b end 2
期望结果:
Status=‘start’并且count(type=1)count(type=2)
Group by name
得到列为:
Name 时长 type1次数合计 type2次数合计
我用
Select t.name,count(status) s1,sum(type=1) t1,sum(type=2) t2
From table1 t
where status=’start’
group by name
不正确
请问这个语句怎么写呀?
...全文
967打赏收藏
oracle单表查询需要用对一列拆分,如何处理呀。
Table1 Idname status type 1 a start 1 2 b end 2 3 a start 1 4 b end 2 5 a start 1 6 b end 2 7 a start 1 8 b end 2 期望结果: Status=‘start’并且count(type=1)count(type=2) Group by name 得到列为: Name 时长 type1次数合计 type2次数合计 我用 Select t.name,count(status) s1,sum(t