Hello,
I am a begginer and have the following doubt:
I have a tables with the columns "client", "month", "credit1", "credit2", "credit3". The column month goes from 1 to 3 and I did the queries below:
SELECT sum(credit1) AS total1
FROM account
WHERE month=1
GROUP BY month;
SELECT sum(credit2) AS total2
FROM account
WHERE month=2
GROUP BY month;
SELECT sum(credit3) AS total3
FROM account
WHERE month=3
GROUP BY month;
The situation is: If my table has thousands of clients and 60 months, how can I optimize the query using CASE ?
I would appreciate if someone could help me.
Thanks