select - Return MAX After Selection -
i new sql queries , having issue getting max of column speedo below current query
select tblvehicle.rego ,tbljob.speedo ,tbljob.dateentered tbljob inner join tblvehicle on tbljob.vehicle_id = tblvehicle.id jobtype_id = 2 order rego
which outputs
rego speedo dateentered 000jkc 147729 2010-05-10 10:56:55.040 000jkc 150145 2010-06-02 13:57:15.470 000jkc 169553 2011-01-06 12:24:09.143 000jkc 155149 2010-07-21 14:58:20.777 000jkc 157882 2010-09-17 16:39:48.480 000jkc 165660 2010-11-29 08:20:39.453 000jkc 164339 2010-11-18 16:19:19.213 000jkc 155149 2010-08-11 06:16:28.180 000rqd 65 2011-11-21 09:27:31.693 000rqd 6978 2012-03-06 15:18:06.987 000rqd 6766 2012-02-24 13:28:47.603 000rqd 12130 2012-08-28 09:29:18.027 000rqd 12145 2012-08-27 14:57:17.330 000rqd 21550 2013-04-15 19:30:30.160 000rqd 23640 2013-05-22 16:16:33.880
now max(speedo) of each rego only.
the max() function returns largest value of selected column.
select tblvehicle.rego , max( tbljob.speedo ) ,tbljob.dateentered tbljob inner join tblvehicle on tbljob.vehicle_id = tblvehicle.id jobtype_id = 2 order rego
Comments
Post a Comment