| 
	
 | 
 Posted by pltaylor3 on 06/30/06 12:17 
I have a query set up that returns the data that I would like, but I 
would only like the latest data for each vehicle number.  The query I 
have set up is 
 
SELECT     TOP 100 PERCENT dbo.vwEvents.EventName, 
dbo.luSessionAll.SessionName, dbo.luOuting.OutingNumber, 
dbo.luVehicle.VehicleName, dbo.luOuting.OutingID, 
dbo.tblOutings.OutingStartTime,dbo.tblSessions.SessionDate,dbo.tblSessions.SessionStartTime 
FROM         dbo.vwSessions INNER JOIN dbo.vwEvents ON 
dbo.vwSessions.Event = dbo.vwEvents.EventID 
INNER JOIN 
                      dbo.luSessionAll ON dbo.vwEvents.EventID = 
dbo.luSessionAll.Event INNER JOIN 
                      dbo.luOuting ON dbo.luSessionAll.SessionID = 
dbo.luOuting.SessionID INNER JOIN 
                      dbo.luVehicle ON dbo.luSessionAll.Vehicle = 
dbo.luVehicle.VehicleID INNER JOIN 
                      dbo.tblOutings ON dbo.luOuting.OutingID = 
dbo.tblOutings.OutingID INNER JOIN 
                      dbo.tblSessions ON dbo.tblOutings.[Session] = 
dbo.tblSessions.SessionID 
GROUP BY dbo.vwEvents.EventName, dbo.luSessionAll.SessionName, 
dbo.luOuting.OutingNumber, dbo.luVehicle.VehicleName, 
dbo.luOuting.OutingID, dbo.tblOutings.OutingStartTime, 
dbo.tblSessions.SessionStartTime, dbo.tblSessions.SessionDate 
ORDER BY dbo.luVehicle.VehicleName, dbo.tblSessions.SessionDate, 
dbo.tblSessions.SessionStartTime, dbo.tblOutings.OutingStartTime 
 
this returns all the outings.  I would like the outing that has, in 
order of importance, the latest session date, latest session time and 
latest outing start time.  Outing start time can sometimes be <<Null>> 
but the other two always have values.  How would I go about doing this? 
thanks in advance for any help
 
  
Navigation:
[Reply to this message] 
 |