我有一个表lot_bill_of_operations
与行和表lot_bill_of_lots_serial_xref
其中有序列号和时间戳列。这些表格通过主键bol_id
相关联。加入两个表,在三个列的行数列其中的语句
我想计算三个班次按行传递有多少个序列号,但每个子查询都有相同的结果。
下面是该查询:
select lot_bill_of_operations.wc_line_code,
(select count(part_sn) from lot_bill_of_lots_serial_xref
where lot_bill_of_lots_serial_xref.time_stamp between '07-MAY-17 06:00:00'
and '07-MAY-17 14:00:00'
group by lot_bill_of_operations.wc_line_code)firstshift,
(select count(part_sn) from lot_bill_of_lots_serial_xref
where lot_bill_of_lots_serial_xref.time_stamp between '07-MAY-17 14:00:00'
and '07-MAY-17 22:00:00'
group by lot_bill_of_operations.wc_line_code)secondshift,
(select count(part_sn) from lot_bill_of_lots_serial_xref
where lot_bill_of_lots_serial_xref.time_stamp between '07-MAY-17 22:00:00'
and '08-MAY-17 06:00:00'
group by lot_bill_of_operations.wc_line_code)thirdshift
FROM lot_bill_of_operations inner JOIN lot_bill_of_lots_serial_xref
ON lot_bill_of_operations.bol_id = lot_bill_of_lots_serial_xref.bol_id
group by lot_bill_of_operations.wc_line_code
这里是获取结果:
我在做什么错?
给一些样本的数据和预期的输出? – Utsav