|A|B|C
|1|1|100
|1|1|200
|2|1|300
|2|4|50
|2|1|100
|3|1|500
Suppose you have columns A, B, and C in a table with MySQL, and the values are similar to those above.
I'd like to extract the product of B and C of each row in a row where the value of A is equal, and the value of A is 500 or more, avoiding duplication. What kind of command would it be?
(Example)
If A is 1, 1*100+1*200=300
If A is 2, 1*300+4*50+1*100=600
If A is 3, 1*500=500
Therefore, 2 and 3 are acquired.
There is no twist, but if you follow the question,
SELECTA
FROMT
GROUP BY A
HAVING 500<=SUM(B*C);
© 2024 OneMinuteCode. All rights reserved.