Skip to content
Advertisement

What is the best way to get a derived status column based on existing result

I have a table :


For a test there can be multiple run/execution. Each run have a result. here for result column, 0 is fail and 1 is pass. I want to query –if all the run PASS for test, the OverallStatus is PASS –If all the run Faile for a test, the OverallStatus is FAIL –If some of them pass and some of them fialed then OverallStaus is DEFECT

I want to get an output from the above table like

testId |numOfRun |OverallStatus

1 | 4 |Defect

2 | 1 |FAIL

3 | 1 |PASS

4 | 3 |PASS

5 | 3 |FAIL

6 | 3 |Defect



Advertisement

Answer

You can use conditional aggregation

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