catacaustic
Wannabe Access Hacker
- Local time
- Yesterday, 20:23
- Joined
- Jan 3, 2007
- Messages
- 14
Hello all. I've got the query:
and it's not working properly.
It gets the correct values fine, but I have problems where a single record in tblCustomer corresponds to two seperate records in tblTicketType that has the first record of TicketType_subscriber set to 'True' and the second to 'False'. This results in bringing up the same customer ID, etc twice in my report.
The only way that I know that I can get around this (in MySQL anyway) is to use a GROUP BY statement, that'd make it look like
Anyone got any ideas of how to get around this?
Code:
SELECT DISTINCT tblCustomer.Customer_id, tblCustomer.Customer_firstName, tblCustomer.Customer_lastName, tblTicketType.TicketType_subscriber
FROM (tblCustomer INNER JOIN tblAttendance ON tblCustomer.Customer_id = tblAttendance.Customer_id) LEFT JOIN tblTicketType ON tblAttendance.TicketType_id = tblTicketType.TicketType_id
WHERE (((tblTicketType.TicketType_subscriber)=True) AND ((Year([tblAttendance].[Attendance_date]))=2006));
It gets the correct values fine, but I have problems where a single record in tblCustomer corresponds to two seperate records in tblTicketType that has the first record of TicketType_subscriber set to 'True' and the second to 'False'. This results in bringing up the same customer ID, etc twice in my report.
The only way that I know that I can get around this (in MySQL anyway) is to use a GROUP BY statement, that'd make it look like
Unfortunately, Access won't allow a GROUP BY clause like this without every field that I'm selecting being included, and that means that because there's two distinct values for TicketType_subscriber that the record still comes up twice.SELECT DISTINCT tblCustomer.Customer_id, tblCustomer.Customer_firstName, tblCustomer.Customer_lastName, tblTicketType.TicketType_subscriber
FROM (tblCustomer INNER JOIN tblAttendance ON tblCustomer.Customer_id = tblAttendance.Customer_id) LEFT JOIN tblTicketType ON tblAttendance.TicketType_id = tblTicketType.TicketType_id
WHERE (((tblTicketType.TicketType_subscriber)=True) AND ((Year([tblAttendance].[Attendance_date]))=2006)) GROUP BY tblCustomer.Customer_id;
Anyone got any ideas of how to get around this?