Sub Query [Resolved]
Does anyone know if it is possible to use the DISTINCT keyword on one particular field, but yet pull up multiple fields in the query? Or another way, where your query will pull up records based on any unique value for a certain field, but also pull up a bunch of other fields as well. I am pretty sure you can do this using some kind of sub query, but I am not so good with those so if someone can help me set it up it would be great.
Here is my query
I want to grab all records that have a unique Class only. If I were to use Distinct in front, it would grab any record that has a distinct max config and class, but I just want it based on class.
Does anyone know if it is possible to use the DISTINCT keyword on one particular field, but yet pull up multiple fields in the query? Or another way, where your query will pull up records based on any unique value for a certain field, but also pull up a bunch of other fields as well. I am pretty sure you can do this using some kind of sub query, but I am not so good with those so if someone can help me set it up it would be great.
Here is my query
Code:
sSQLQuery = "SELECT [Max Config], Class FROM AircraftInfo WHERE KitchenID = '" & txtKitchenID _
& "' AND [Customer ID] = '" & txtCustomerID _
& "' AND [Aircraft] = '" & "" & rsFlightRecord.Fields("Aircraft") _
& "' AND [Model] = '" & "" & rsFlightRecord.Fields("Model") _
& "' AND [Effective Date] <= #" & txtFlightDate _
& "# AND ([Discontinue Date] >= #" & txtFlightDate _
& "# OR [Discontinue Date] IS NULL) ORDER BY Class"
I want to grab all records that have a unique Class only. If I were to use Distinct in front, it would grab any record that has a distinct max config and class, but I just want it based on class.
Last edited: