Skip to content
Advertisement

SQL Query to get the compliance status

I’m trying to get the following query constructed

I got a table called client_vendor as follows. This stores the details of answers provided by client against a vendor for 4 questions.

client_vendor

The client can answer either Y or N or not give a response to the questions asked. Here clientid=100 has answered as follows q1=Y,q2=N,q3=N,q4="" against vendorid=1.

We have another table called vendor_compliance

vendor_compliance

This table indicates compliance,if the client answers for the questions the expected values.

Here if the client answers to q1=Y and q3=N then he is compliant. The answers to q2 and q3 are irrelevant for vendorid=1 to indicate compliance.

I wish to create a query which will show up the clientid, vendorid and the compliance status as follows

Advertisement

Answer

You can use join with some case logic:

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