Quote:
|
Now I need to get all Customers who 've rent e.g. a Mercedes but on a second column having an indication if he also rent an Alfa Romeo. That means that as soon as the query reaches the Car_ID of Mercedes it returns that Customer_ID, but in the same time it should check if there is another row with the same Customer_ID and the Car_ID for Alfa Romeo.
|
This can be interpreted in many ways:
- you want an overview of all the brands a customer has rented (Pat's solution/interpretation)
- you want all customers who have rented a Mercedes AND an Alfa Romeo.
(my first solution/interpretation)
- you want all customers who have rented a Mercedes AND an a car of any other brand. (my second solution/interpretation)
- you want all customers who have rented exactly two different brands of cars
- you want all customers who have rented at least two different brands of cars
- What with a customer who has rented a Mercedes twice. You want those too, or only when they rent other brands too. (your data model won't allow to store that data)
For each of the above questions the query must be adjusted. The performance could vary greatly among the queries.
Quote:
|
Do you mean, the way I express it is not clear?
|
You're the only one on this forum who knows exactly what your business rules are. It's hard for us to grasp what the real question is behind a few lines of explanation. Something that works very well is to give some sample data, the result you want and some extra explanation why some data are in the result set and others not.