How to append a column data to a MAX Aggregate function in SQL? -
column names: name , reading , channel , time i'm trying find max value each distinct name . each name has many values read on time interval of once every hour. goal pick out max value each distinct name , record time interval occurred in. so far have gotten code: select name, max(reading) "max_reading", data, channel, time interval_data group name, data, channel however, gives me error saying time has aggregated or grouped by. there easy way append time max value occurred @ output , not have perform grouped by/aggregate function on column? sample data: name reading data channel time 1 1 1 1 1/15/2015 09:00 1 3 1 1 1/15/2015 10:00 1 2 1 1 1/15/2015 11:00 1 5 1 1 1/15/2015 12:00 2 2 1 1 1/15/2015 09:00 2 4 1 1 1/15/2015 10:00 2 6 ...