I want to find maximum column value, i says:
SELECT
Segment_ID.Segment_ID,
Intensity.Date,
Intensity.NumAll,
Intensity.AverageDailyIntensCar,
MAX(Intensity.AverageDailyIntensCar) as maxvalue,
Track.the_geom
FROM Segment_ID
LEFT JOIN Track ON Segment_ID.Segment_ID=Track.Segment_ID
LEFT JOIN Intensity ON Segment_ID.Segment_ID=Intensity.Segment_ID
where (DATEPART(yy, Intensity.Date) = 2009
AND DATEPART(mm, Intensity.Date) = 08
AND DATEPART(dd, Intensity.Date) = 14)
But get error:
Column `Segment_ID.Segment_ID` is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
So i add GROUP BY Segment_ID.Segment_ID
but get same error for next column.
How to use max() function correctly?
UPD
I think i asking wrong. Bucouse i expect that max() function return me row and set in column MAX(Intensity.AverageDailyIntensCar) as maxvalue
a max value of Intensity.AverageDailyIntensCar
column. Thats right?