OK, decided to make a summary table and test on that. I made a table like this (in pgsql):
create table test (
roomblocks_id int,
blockdate date,
qty int,
initialprivate int,
nom_private int,
price text,
rooms_id int,
Contractsroomblocks_ID int,
private int);
COPY test (roomblocks_id, blockdate, qty, initialprivate, nom_private, price, rooms_id, contractsroomblocks_id, private) FROM stdin;
31 2007-09-04 5 5 0 80129139139 \N \N \N
31 2007-09-05 85 55 0 80129139139 174 73 0
31 2007-09-06 105 55 0 80129139139 174 74 0
31 2007-09-07 85 55 0 80129139139 173 75 1
31 2007-09-07 85 55 0 80129139139 174 75 0
31 2007-09-07 85 55 0 80129139139 175 75 0
31 2007-09-08 5 5 0 80129139139 173 76 1
32 2007-09-04 5 5 0 80129139139 \N \N \N
32 2007-09-05 256 15 0 80129139139 \N \N \N
32 2007-09-06 284 15 0 80129139139 \N \N \N
32 2007-09-07 256 15 0 80129139139 \N \N \N
32 2007-09-08 5 5 0 80129139139 \N \N \N
\.
When I ran a simplified version of your query:
select
Roomblocks_ID,
BlockDate,
Qty,
InitialPrivate,
nom_private,
price,
rooms_id,
Contractsroomblocks_ID,
private,
sum(private)
from test
group by
roomblocks_id,
blockdate;
I got the expected error:
ERROR: column "test.qty" must appear in the GROUP BY clause or be used in an aggregate function
After adding requisite aggregate functions (I guessed which ones seems most likely to work right) I had this query:
select
Roomblocks_ID,
BlockDate,
sum(Qty),
sum(InitialPrivate),
sum(nom_private),
max(price),
count(rooms_id),
count(Contractsroomblocks_ID),
sum(private)
from test
group by
roomblocks_id,
blockdate;
roomblocks_id | blockdate | sum | sum | sum | max | count | count | sum
---------------+------------+-----+-----+-----+-------------+-------+-------+-----
32 | 2007-09-04 | 5 | 5 | 0 | 80129139139 | 0 | 0 |
32 | 2007-09-05 | 256 | 15 | 0 | 80129139139 | 0 | 0 |
32 | 2007-09-06 | 284 | 15 | 0 | 80129139139 | 0 | 0 |
32 | 2007-09-07 | 256 | 15 | 0 | 80129139139 | 0 | 0 |
32 | 2007-09-08 | 5 | 5 | 0 | 80129139139 | 0 | 0 |
31 | 2007-09-07 | 255 | 165 | 0 | 80129139139 | 3 | 3 | 1
31 | 2007-09-08 | 5 | 5 | 0 | 80129139139 | 1 | 1 | 1
31 | 2007-09-05 | 85 | 55 | 0 | 80129139139 | 1 | 1 | 0
31 | 2007-09-06 | 105 | 55 | 0 | 80129139139 | 1 | 1 | 0
31 | 2007-09-04 | 5 | 5 | 0 | 80129139139 | 0 | 0 |
(10 rows)
huh, got the right number in the test version. Not sure if the lack of joins is making it get the right answer or what.