Hi All,
I came across a weird situation while running a query with group by.
I executed 2 queries:
1)
select trunc(hu_ts,'DAY',1),hu_ho_id,hu_stream_id,sum(hu_usage) from
se_dwh.homes_usage_hour where hu_ho_id in (4720,6854) group by
trunc(hu_ts,'DAY',1),hu_ho_id ,hu_stream_id;
| 2015-03-19 00:00:00.000 | 4720 | 0
| 0.45599999999999996
|
| 2015-03-19 00:00:00.000 | 6854 | 0
| 2.167
|
2)
select trunc(hu_ts,'DAY',1),hu_ho_id,hu_stream_id,sum(hu_usage) from
se_dwh.homes_usage_hour where hu_ho_id in (4720) group by
trunc(hu_ts,'DAY',1),hu_ho_id ,hu_stream_id;
| 2015-03-19 00:00:00.000 | 4720 | 0
| 8.405999999999999
|
The only difference is that in the first case I included 2 ids(4720,6854)
and in the other one only 1 (4720).
The result for hu_ho_id=4720 should be the same in both case but it isn't
(0.45 vs 8.4).
The second result(8.4) is correct.
Am I doing something wrong?
Regards,
Marek