Skip to content
Advertisement

How to combine two queries with case statement

How to combine two queries with case statement

query1

query2

Expected output:

Advertisement

Answer

With conditional aggregation:

The conditions where by_user = '3' or where by_user <> '3' are checked with a CASE expression, so they are removed from the WHERE clause.

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