I'm very new in SQL and have to modify this existing code:
CONCAT(
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'series_title'),
' : ',
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'episode_title')
) as complete_title,
My question is how to write if 'series_title' is missing?
I've put in this right before CONCAT, but it indicates that something is wrong/missing:
WHERE
(SELECT value.string_value FROM UNNEST(event_params) WHERE key IS NULL)
THEN
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'episode_title') as complete_title,
ELSE
OK, some completions:
I have this query in BigQuery, which is NoSQL(?).
The reason of the modification is that the 'series_title'
value, which we use to create the complete_title
value, is missing for a part of our programs. So that I try to get pull out in these case is the 'episode_title'
solely as complete_title
. Otherwise - if both exist - 'series_title'
and 'episode_title'
together gets as complete_title
.
event_params is the parameters we have available like this: enter image description here
我认为你想要NOT EXISTS
:
WHERE NOT EXISTS (SELECT 1 FROM UNNEST(event_params) WHERE key = 'series_title')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.