Skip to content
Advertisement

Derive results if the result contains all values from another table

I am trying to get all the names of the customer who have purchase all the treatment packages (A101, A102, A103)

The following is an illustration of the tables I have:

Customer

Account

AccountLine

Treatment

In my statement, I wrote it as:

The results that I derived from the above statement has instead return me customer who have purchase any of the treatment packages. Help, please?

P.S – I cannot display both the given name and family name together (SELECT c.givenname, c.familyname in my first line) as this results in an error stating not a GROUP BY expression, why is that so?

Advertisement

Answer

You can try the below – use a having clause to check who’ve purchased all three products

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement