Skip to content
Advertisement

Trying to write a query to specify if a customer has completed two types of a specific column

I have this table (resedtl) below…

It contains information about a customer and the resType and the status of it. I am trying to determine if a customer has completed (status = done) both types of “RES” or only one or only two.

enter image description here

I want to return something like this, where if custId is done for both resType 1 and 2 then I want to return both. else just one or just two.

enter image description here

So far, I’ve the query written as follows…

I’m wondering if this is the best way to do this or if there is a better solution to this..

The query I have seem to be over complicated.

Advertisement

Answer

Custld result
123 both
124 just one
125 just one
126 just two

Fiddle

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