Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Please help with this query. Not so good at access

Author  Topic 

mr.modus
Starting Member

27 Posts

Posted - 2007-11-05 : 15:15:55
Hello there,

I've been pulling my hair out with this and any help would be fantastic.

I have a query where I'm trying to get info out of three tables and I'm not sure how to Join and how to Group it.

My tables (with only the relevant fields) are:

tblPassengers
- PassengerID (Number)
- BookingID (text)
- FlightNumber (text)
- FlightCompleted (Yes/No)

tblBookings
- BookingDate (Date/Time)
- BookingID (text)

tblFlights
- FlightNumber (text)
- FlightDate (Date/Time)
- CityName (text)

Relations are:
tblPassengers.BookingID = tblBookings.BookingID
tblPassengers.FlightNumber = tblFlights.FlightNumber


What I want to do is get a count of all passengers (Count(tblPassengers.PassengerID)that have a completed flight (tblPassengers.FlightCompleted = yes) and that have flown within 30 months of their purchase (tblFlights.FlightDate < DateAdd("m",30,tblBookings.BookingDate)) within the last five years (tblFlights.FlightDate > 1/1/2003) grouped by CityName and Year.

So the result I would want would be something like:

Count Year City
453 2003 London
285 2003 Hockley Valley
138 2003 Another City
658 2004 London
260 2004 Hockley Valley


Any help would be awesome!

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-06 : 19:39:16
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92126

answered there.
Go to Top of Page
   

- Advertisement -