This data as json
id | file | clicks | impressions | text | url | spend_amount | spend_currency | created | ended | target_names |
---|
CREATE VIEW ads_with_targets as select ads.*, json_group_array(targets.name) as target_names from ads join ad_targets on ad_targets.ad_id = ads.id join targets on ad_targets.target_id = targets.id group by ad_targets.ad_id