MySQL Forums
Forum List  »  MySQL Query Browser

need help query - mathematical function
Posted by: Guillaume Couture
Date: November 11, 2013 11:57PM

Hello,

I need a bit of help on a mathematical function,

Folling query will result 2 lines per "lot" like this:

group / style / lot / section number / section code / q1 / q2 /q3 / q4 / ...
aaaaa / sssss / 123 / 01qqqqqqqqqqqq / 111111111111 / 55 / 77 /88 / 99 / ...
aaaaa / sssss / 123 / 01qqqqqqqqqqqq / 222222222222 / 10 / 20 /20 / 10 / ...
aaaaa / sssss / 321 / 01qqqqqqqqqqqq / 111111111111 / 11 / 22 /44 / 55 / ...
aaaaa / sssss / 321 / 01qqqqqqqqqqqq / 222222222222 / 10 / 23 /33 / 10 / ...

each "lot" result 2 diff "section code" (2 lines)

Question is : how do I make a subtraction between the 2 "section code" for the colums q1 q2 q3 q4 q5 ... ?


expected results:

group / style / lot / section number / q1 / q2 /q3 / q4 / ...
aaaaa / sssss / 123 / 01qqqqqqqqqqqq / 45 / 57 /68 / 89 / ...
aaaaa / sssss / 321 / 01qqqqqqqqqqqq / 1 / -1 /11 / 45 / ...




query so far :

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,


Thanks !

Options: ReplyQuote


Subject
Written By
Posted
need help query - mathematical function
November 11, 2013 11:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.