Skip to content
Advertisement

How to union all, but separate the columns in mySQL

The first query returns the data for the last 7 days, and returns 90 in total, while the second query returns data for the previous 7 days, returns 55 in total.

Current output is:

But the output should be:

Advertisement

Answer

You can use conditional aggregation:

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