Question: generate an sql query where we have to check whether the patients are double positive or triple postive based on the following condition: If MYC

generate an sql query where we have to check whether the patients are double positive or triple postive based on the following condition:
If MYC positive, BCL2 positive then double positive
If MYC positive, BCL6 positive then double positive
If MYC positive, BCL2 positive and BCL6 positive, then triple positive.
There are three columns to check it MYC, BCL2,BCL6 which have corresponding values metioned in the above condition in their respective columns.
I have created a query as follows :
SELECT *,
CASE
WHEN "COUNT_DISTINCT(MYC)"='MYC' AND "COUNT_DISTINCT(BCL2)"='BCL2' THEN 'Double Hit'
WHEN "COUNT_DISTINCT(MYC)"='MYC' AND "COUNT_DISTINCT(BCL6)"='BCL6' THEN 'Double Hit'
WHEN "COUNT_DISTINCT(MYC)"='MYC' AND "COUNT_DISTINCT(BCL2)"='BCL2' AND "COUNT_DISTINCT(BCL6)"='BCL6' THEN 'Triple Hit'
ELSE 'None'
END AS Hit_Status
FROM #table# AS "table";
but the output is returning the value double positive even if all the three columns contain the corresponding columns.
eg. MYC is postive, BCL2 is positive, BCL6 is positive still returns double positive instead of triple positive.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!