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.Ev entName,
dbo.luSessionAl l.SessionName, dbo.luOuting.Ou tingNumber,
dbo.luVehicle.V ehicleName, dbo.luOuting.Ou tingID,
dbo.tblOutings. OutingStartTime ,dbo.tblSession s.SessionDate,d bo.tblSessions. SessionStartTim e
FROM dbo.vwSessions INNER JOIN dbo.vwEvents ON
dbo.vwSessions. Event = dbo.vwEvents.Ev entID
INNER JOIN
dbo.luSessionAl l ON dbo.vwEvents.Ev entID =
dbo.luSessionAl l.Event INNER JOIN
dbo.luOuting ON dbo.luSessionAl l.SessionID =
dbo.luOuting.Se ssionID INNER JOIN
dbo.luVehicle ON dbo.luSessionAl l.Vehicle =
dbo.luVehicle.V ehicleID INNER JOIN
dbo.tblOutings ON dbo.luOuting.Ou tingID =
dbo.tblOutings. OutingID INNER JOIN
dbo.tblSessions ON dbo.tblOutings.[Session] =
dbo.tblSessions .SessionID
GROUP BY dbo.vwEvents.Ev entName, dbo.luSessionAl l.SessionName,
dbo.luOuting.Ou tingNumber, dbo.luVehicle.V ehicleName,
dbo.luOuting.Ou tingID, dbo.tblOutings. OutingStartTime ,
dbo.tblSessions .SessionStartTi me, dbo.tblSessions .SessionDate
ORDER BY dbo.luVehicle.V ehicleName, dbo.tblSessions .SessionDate,
dbo.tblSessions .SessionStartTi me, 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
would only like the latest data for each vehicle number. The query I
have set up is
SELECT TOP 100 PERCENT dbo.vwEvents.Ev entName,
dbo.luSessionAl l.SessionName, dbo.luOuting.Ou tingNumber,
dbo.luVehicle.V ehicleName, dbo.luOuting.Ou tingID,
dbo.tblOutings. OutingStartTime ,dbo.tblSession s.SessionDate,d bo.tblSessions. SessionStartTim e
FROM dbo.vwSessions INNER JOIN dbo.vwEvents ON
dbo.vwSessions. Event = dbo.vwEvents.Ev entID
INNER JOIN
dbo.luSessionAl l ON dbo.vwEvents.Ev entID =
dbo.luSessionAl l.Event INNER JOIN
dbo.luOuting ON dbo.luSessionAl l.SessionID =
dbo.luOuting.Se ssionID INNER JOIN
dbo.luVehicle ON dbo.luSessionAl l.Vehicle =
dbo.luVehicle.V ehicleID INNER JOIN
dbo.tblOutings ON dbo.luOuting.Ou tingID =
dbo.tblOutings. OutingID INNER JOIN
dbo.tblSessions ON dbo.tblOutings.[Session] =
dbo.tblSessions .SessionID
GROUP BY dbo.vwEvents.Ev entName, dbo.luSessionAl l.SessionName,
dbo.luOuting.Ou tingNumber, dbo.luVehicle.V ehicleName,
dbo.luOuting.Ou tingID, dbo.tblOutings. OutingStartTime ,
dbo.tblSessions .SessionStartTi me, dbo.tblSessions .SessionDate
ORDER BY dbo.luVehicle.V ehicleName, dbo.tblSessions .SessionDate,
dbo.tblSessions .SessionStartTi me, 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
Comment