I would like to get just the max date value (e.g. just the 2014 result), but if I remove the water_type from the group_by it gives an error to do with field not being part of the aggregate.
example:
this query:
SELECT Location_Code, water_type, max(Sampled_Date_Time) as maxdate
FROM [LChem1_Chemistry] lc1
where Location_Code = 'mb340'
and water_type is not null
group by Location_Code, water_type
gets this:
Location_Code water_type maxdate
MB340 Group2 2013-09-27 14:00:00
MB340 SubGroup2 2014-03-04 00:00:00
however i only want the 2014 result (but keep the water_type in the resulting table.
thanks
actually this is a better example of input data:
Location_Code water_type maxdate
MB117 Group2 2/07/2012 12:58
MB331 Group2 28/02/2013 0:00
MB340 Group2 27/09/2013 14:00
MB340 SubGroup2 4/03/2014 0:00
MB117 Group2 3/07/2012 12:58
MB331 Group2 28/05/2013 0:00
and i want rows 5,7 & 2 in the resulting table.