数学関数について少し助けが必要です。
次のクエリでは、次のlot
ように 2 行ずつ結果が返されます。
group | style | lot | section | q1 | q2 |q3 | q4 | ...
aaaaa | sssss | 123 | 111111 | 55 | 77 | 88 | 99 | ...
aaaaa | sssss | 123 | 222222 | 10 | 20 | 20 | 10 | ...
aaaaa | sssss | 321 | 111111 | 11 | 22 | 44 | 55 | ...
aaaaa | sssss | 321 | 222222 | 10 | 23 |33 | 10 | ...
各lot
結果 2 差分section code
(2 行)
質問section code
:列 q1 q2 q3 q4 q5 ...の 2 の間で減算を行うにはどうすればよいですか?
予想された結果:
group | style | lot | q1 | q2 |q3 | q4 | ...
aaaaa | sssss | 123 | 45 | 57 |68 | 89 | ...
aaaaa | sssss | 321 | 1 | -1 |11 | 45 | ...
これまでのクエリ:
SELECT DISTINCT gp_style_gr.code_groupe, po_lot.num_style, po_lot_sp.Num_lot,
po_lot_sp.num_secti, po_lot_se.code_secti, po_lot.terminer, po_lot.date_livraison,
po_lot_sp.qte_1, po_lot_sp.qte_2, po_lot_sp.qte_3, po_lot_sp.qte_4, po_lot_sp.qte_5,
po_lot_sp.qte_6, po_lot_sp.qte_7, po_lot_sp.qte_8, po_lot_sp.qte_9, po_lot_sp.qte_10,
po_lot_sp.qte_11, po_lot_sp.qte_12, po_lot_sp.qte_13, po_lot_sp.qte_14, po_lot_sp.qte_15,
po_lot_sp.qte_16, po_lot_sp.qte_17, po_lot_sp.qte_18, po_lot_sp.qte_19, po_lot_sp.qte_20,
po_lot_sp.qte_21, po_lot_sp.qte_22, po_lot_sp.qte_23, po_lot_sp.qte_24, po_lot_sp.qte_25,
po_lot_sp.qte_26, po_lot_sp.qte_27, po_lot_sp.qte_28, po_lot_sp.qte_29, po_lot_sp.qte_30
FROM po_lot_sp
LEFT OUTER JOIN po_lot_se ON po_lot_se.num_lot = po_lot_sp.num_lot
and po_lot_se.num_secti = po_lot_sp.num_secti
LEFT OUTER JOIN po_lot ON po_lot.num_lot = po_lot_sp.num_lot
LEFT OUTER JOIN gp_style_gr ON gp_style_gr.num_style = po_lot.num_style
WHERE
((gp_style_gr.code_groupe = 'INSTOCK') and (po_lot.terminer = '0')
and (po_lot_se.code_secti = '01')) or ((gp_style_gr.code_groupe = 'INSTOCK')
and (po_lot.terminer = '0') and (po_lot_se.code_secti = '09'))
ORDER BY gp_style_gr.code_groupe, po_lot.num_style, po_lot_sp.Num_lot,
po_lot_sp.num_secti, po_lot_se.code_secti, po_lot.terminer, po_lot.date_livraison,
ありがとう !