TheQuestioner
Programmer
I have an SQL question fellow developers. I have a three column table called [tblFlightLegs]. The columns are ([ID] as Int, [FlightNo] as NVarchar, and [IDMaster] as Int). The nature of this table is that many rows can be associated to the same [IDMaster].
What I want to do is create a view where only the lowest [ID] for each [IDMaster] is returned along with it's accompanying [FlightNo]. I've got as far as:-
SELECT min(tblFlightLegs.ID) as id,
min(tblFlightLegs.FlightNo) as [FlightNo],
tblFlightLegs.IDMaster
FROM tblFlightLegs
GROUP BY tblFlightLegs.IDMaster
but this doesn't actually return the lowest [ID]. I'm using SQL Server 7. Please help.
What I want to do is create a view where only the lowest [ID] for each [IDMaster] is returned along with it's accompanying [FlightNo]. I've got as far as:-
SELECT min(tblFlightLegs.ID) as id,
min(tblFlightLegs.FlightNo) as [FlightNo],
tblFlightLegs.IDMaster
FROM tblFlightLegs
GROUP BY tblFlightLegs.IDMaster
but this doesn't actually return the lowest [ID]. I'm using SQL Server 7. Please help.