0

I would like to filter out null values from a specific column in this case "Account" on a union query how can i do this?

The query that I am working on is this:

SELECT Account, Campaign_name, Ad_group_name, Date, Keyword, Impressions, Clicks, Cost__GBP_, Conversions FROM table1 UNION ALL

SELECT Account, Campaign_name, Ad_group_name, Date, Keyword, Impressions, Clicks, Cost__GBP_, Conversions FROM table2

Someone can help me in this? Thanks

4

1 回答 1

0

Each query is evaluated separately in a union query. So you should add WHERE filters to each of them.

SELECT Account, Campaign_name, Ad_group_name, Date, Keyword, Impressions, Clicks, Cost__GBP_, Conversions 
FROM table1 
WHERE Account is not NULL

UNION ALL

SELECT Account, Campaign_name, Ad_group_name, Date, Keyword, Impressions, Clicks, Cost__GBP_, Conversions 
FROM table2
WHERE Account is not NULL
于 2021-01-28T16:53:16.950 回答