I have the following table backup which combines data of hours, persons, type of backup and date of backup:
data | type | persons | hours
==============================================
2015-06-12 15 4 8
2015-06-12 15 4 8
2015-06-12 15 4 8
2015-06-12 15 4 8
2015-06-13 14 2 4
2015-06-13 14 2 4
I'm trying to write a query which will return following result:
data | type | persons | hours
==============================================
2015-06-12 15 4 32
2015-06-13 14 2 8
My query looks like this:
SELECT "data", "type", SUM("hours"), "persons" FROM "backup" GROUP BY "type", "data", "persons" ORDER BY "data"
but it does'nt work the way I want :(
EDIT:
after using of this query:
SELECT "data", "type", "persons", SUM("hours") AS "hours" FROM "backup" WHERE "project" = '2000030' GROUP BY "type", "data", "persons" ORDER BY "data"
SQL returns this data:
data | type | persons | hours
==========================================
2011-12-16 | 2003774 | 9 | 12
2011-12-16 | 2003774 | 10 | 12
but there should be:
data | type | persons | hours
==========================================
2011-12-16 | 2003774 | 9 | 54
In DB I have 9 records (one record per person), in each person cell is 9, and in each hours cell is 9. I need to sum hours per date and per type of backup (support).