mysqli - Condition based grouping in mysql -
my database table list
product_no | c_product_no| qty | price 1001 | 4306-0 | 15 | 100 1001 | 4306-0 | 15 | 100 665 | 5906-7 | 981 | 2547 783 | 5906-7 | 1221 | 200 783 | 590111 | 5 | 300 783 | 5906-7 | 1221 | 200
and expecting out put
product_no | c_product_no| qty | price 1001 | 4306-0 | 30 | 100 665 | 5906-7 | 981 | 2547 783 | 5906-7 | 2442 | 200 783 | 590111 | 5 | 300
my condition in grouping product_no , c_product_no , price same grouped data , sum of quenty
select product_no, c_product_no, sum(qty), price table group product_no, c_product_no, price
this answer assumes price same records have same (product_no, c_product_no). group data product_no, c_product_no , price (actually not necessary. including price in group can include in select part).
sum (qty) compute sum of quantity of records same product_no, c_product_no, price combination
Comments
Post a Comment