Skip to content
Advertisement

How do I merge two SELECT queries with different WHERE clauses

I’m trying to write query on two different selects with different WHERE clause and using GROUP BY. I browsed for examples but mine is different since I have multiple fields for SELECT. Here is example data:

These are the queries I would like to merge:

I tried 2 methods as under:

Both give Error:

Please guide

Advertisement

Answer

seems like you just want to group by report_date and source_system:

if you want to have result for specific source systems then you can combine conditions:

you can change order by to show rows in the order you want to show

just to illustrate how to use union :

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