Home > database >  Keep the only ID cases sum of amount
Keep the only ID cases sum of amount

Time:11-16

SELECT * FROM (
The select PARTNO='048001055', attribute='ABCD', ID='1000242451', number='22', amount='1800' UNION ALL
The select PARTNO='948001055', attribute=', ID='1000242452', number='22', amount='600' UNION ALL
The select PARTNO='048001055', attribute='ABCD', ID='1000242453', number='6', amount='400' UNION ALL
The select PARTNO='948001055', attribute=', ID='1000242454', number='6', amount='366' UNION ALL
The select PARTNO='012001079', attribute='powerpoint', ID='1000242455', number='73', amount='900') f


- the result to

048001055 the ABCD 1000242451 22 2400 (note 1800 + 600)
048001055 the ABCD 1000242453 22 766 (note 400 + 366)
Powerpoint 012001079, 1000242455, 73, 900

CodePudding user response:

According to the title you describe, the first and the second is not the same as the ID of the data, why merger summation, the third and fourth,

CodePudding user response:

reference 1st floor RINK_1 response:
title description according to you, the first and the second is not the same as the ID of the data, why merger summation, the third and fourth,

Front for the amount of 9 into business need PARTNO with PARTNO after 8, which is 48001055 and the number of packet summation, but ID must also displayed the following useful

CodePudding user response:

This logic may not forget it

CodePudding user response:

August 18 references 4 floor response:
calculate the logic may indeed blocked

CodePudding user response:

New ask a question, please answer as soon as possible, thank you
  • Related