Let me explain this. I have a table where I have two important fields I need :
The first one is a double, and the second one is a date.
I would like to make a requests that groups entries by YYYY-MM-DD
, and adds each field of the double by group.
For example, I have two entries the same day :
| amount | date
1 | 100 | 2010-01-01
2 | 200 | 2010-01-01
What I need is :
1 | 300 | 2010-01-01
Is that possible ? For the moment here is my request :
SELECT DISTINCT ON (d) amount, to_char(datecreation, 'YYYY-MM-DD') d
FROM mytable
GROUP BY d, amount
ORDER BY d ASC;
What I get is :
1 | 100 | 2010-01-01
It doesn't add the grouped amounts.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…