i have a set of data
product, hour, sales
col1,1,234
col1,1,345
col2,1,456
col2,1,345
col1,2,342
col1,2,6543
col2,2,23
col2,2,634
What I need
col1, 1, 234, 345
what I am getting
col1, 1, 234, 234
col1, 1, 345, 345
select
distinct (hour),
product,
max(sales),
min(sales)
from
table
group by
hour,
product,
sale
I would have thought that the above would give my about 2000 rows but instead it gives me every row. How do I go about pulling distinct columns.
product, hour, sales
col1,1,234
col1,1,345
col2,1,456
col2,1,345
col1,2,342
col1,2,6543
col2,2,23
col2,2,634
What I need
col1, 1, 234, 345
what I am getting
col1, 1, 234, 234
col1, 1, 345, 345
select
distinct (hour),
product,
max(sales),
min(sales)
from
table
group by
hour,
product,
sale
I would have thought that the above would give my about 2000 rows but instead it gives me every row. How do I go about pulling distinct columns.