1

任何人请帮助我。

我有一个查询需要提取数据,这些数据必须显示流程中某个模型的详细信息。

这是我的查询。

    select
x.Sequence as 'Sequence',
x.Process as 'Process',
x.pdt as 'Production Date',
x.mdl as 'Model',
count(x.bigbook) as 'Bigbook Count',
x.sb as 'Smallbook'
from
(
select distinct
'1' as 'Sequence',
'Cutting' as 'Process',
cut_pdt as 'PDT',
cut_shf as 'Shift',
cut_mdl as 'Mdl',
cut_bbn as 'Bigbook',
 count(cut_sbn) as 'SB'
from sum_cut_001 group by cut_bbn) x
group by x.mdl

它显示的那个结果是这样的。

---------|---------|-----------------|-------|----------------|------------------|
Sequence | Process | Production Date | Model | Big book Count | Small Book Count |
---------|---------|-----------------|-------|----------------|------------------|
1        | Cutting |    2012-01-30   |  GSX1 |     3          |        12        |

每个模型有 1 个大本,每个大本有 18 个小本

因此,如果我有 3 本 GSX1 型号的 bigbook,那么输出应该是。

---------|---------|-----------------|-------|----------------|------------------|
Sequence | Process | Production Date | Model | Big book Count | Small Book Count |
---------|---------|-----------------|-------|----------------|------------------|
1        | Cutting |    2012-01-30   |  GSX1 |     3          |        54        |

请帮助我如何正确查询它。

预先感谢。

4

0 回答 0