例如表A:
成本代码 工序名称 工时
BT 钻工 1h
BT 抛光 2h
BP 抛光 1.5h
经过sql筛选后显示的结果如下
成本代码 钻工 抛光
BT 1h 2h
BP 0h 1.5h
sql数据库,从一张表A里取出一个字段,并和本表A另一个字段进行对应?
答案:2 悬赏:70 手机版
解决时间 2021-02-23 21:05
- 提问者网友:眉目添风霜
- 2021-02-23 08:18
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-02-23 08:31
select
a2.成本代码,
(select sum(a3.工时) from A as a3 where a3.成本代码=a2.成本代码 and a3.工序名称=钻工) as 钻工,
(select sum(a4.工时) from A as a4 where a4成本代码=a2.成本代码 and a4.工序名称=抛光) as 抛光,
from A as a2
group by a2.成本代码
a2.成本代码,
(select sum(a3.工时) from A as a3 where a3.成本代码=a2.成本代码 and a3.工序名称=钻工) as 钻工,
(select sum(a4.工时) from A as a4 where a4成本代码=a2.成本代码 and a4.工序名称=抛光) as 抛光,
from A as a2
group by a2.成本代码
全部回答
- 1楼网友:酒者煙囻
- 2021-02-23 08:37
select to_date(a,'yyyy-mm-dd') a ,sum(分组数值类型字段) from 表
group by to_date(a,'yyyy-mm-dd')
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯