求教统计的sql语句写法

ahxjolin 2015-09-01 11:04:54
有如下需求:
inout_info是一张配件出入库流水表,有system,factory,name,in_date,out_date等字段,数据例如:
s1 f1 n1 20150801 20150802
s2 f2 n2 20150801
s1 f1 n3 20150802
s1 f1 n3 20150802
s2 f1 n1 20150802
s1 f1 n1 20150809
要求对out_date is null 的数据,根据不同system,factory,name做数量统计,如结果:
s2 f2 n2 1
s1 f1 n3 2
s2 f1 n1 1
s1 f1 n1 1
求sql写法?
...全文
112 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahxjolin 2015-09-01
  • 打赏
  • 举报
回复
引用 3 楼 xu176032 的回复:
[quote=引用 2 楼 xu176032 的回复:]

select system,factory,name,count(1)
 from 表 where out_date is null 
group by 
where system,factory,name

group by 后面的 where去掉,粘多了。。

select system,factory,name,count(1)
 from 表 where out_date is null 
group by  system,factory,name
好用 我没学过数据库 感谢
xu176032 2015-09-01
  • 打赏
  • 举报
回复
[quote=引用 2 楼 xu176032 的回复:]

select system,factory,name,count(1)
 from 表 where out_date is null 
group by 
where system,factory,name

group by 后面的 where去掉,粘多了。。

select system,factory,name,count(1)
 from 表 where out_date is null 
group by  system,factory,name
xu176032 2015-09-01
  • 打赏
  • 举报
回复

select system,factory,name,count(1)
 from 表 where out_date is null 
group by 
where system,factory,name

这样吗?基础的group by用法啊
ahxjolin 2015-09-01
  • 打赏
  • 举报
回复
顶顶顶~~~

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧