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
不正确请问这个语句怎么写呀?
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
不正确请问这个语句怎么写呀?
解决方案 »
- 创建新表
- 这个怎么做啊!orcal 基础题
- 求助!关于ora-00903,表名无效
- 怎样获取System.Data.OracleClient.dll源码
- 把ORACLE,SHUTDOWN 后,再重启动,出现ORA-01102: ??? EXCLUSIVE ????????
- select ...into 如果select查询语句有多条记录,用select ...into 会不会报错呢?
- 改变索引的的问题!!急!!
- 我想查询表中姓名重复纪录,如何用sql语句完成
- oracle816支持内连接吗?
- win10如何完美卸载oracle11g,请大神指教!!
- [急问]ORACLE 的SQLJ为什么不能支持JBOSS热部署?
- 一个很棘手的问题 晕啊
From table1 t
where status=’start’
group by name
用楼上的方法试过,有许多重复列怎么去除呀
Select distinct t.name,count(status) s1,sum(decode(type,1,1,0)) t1,sum(decode(type,2,1,0)) t2 From table1 t where status=’start’ group by name