home / russian-ads

russian-ads

Custom SQL query returning 29 rows

select
    target_id,
    targets.name,
    count(*) as n,
    json_object(
        "href", "/russian-ads/faceted-targets?targets=" || urllib_quote_plus(
            json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
        ),
        "label", json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
    ) as apply_this_facet,
    json_object(
        "href", "/russian-ads/display_ads?_targets_json=" || urllib_quote_plus(
            json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
        ),
        "label", "See " || count(*) || " ads matching " || json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
    ) as browse_these_ads
from ad_targets
join targets on ad_targets.target_id = targets.id
where
    json_array_length(:targets) == 0 or
    ad_id in (
        select ad_id
        from "ad_targets"
        where "ad_targets".target_id in (select value from json_each(:targets))
        group by "ad_targets".ad_id
        having count(distinct "ad_targets".target_id) = json_array_length(:targets)
    )
    and target_id not in (select value from json_each(:targets))
group by
    target_id order by n desc

Query parameters

target_idnamenapply_this_facetbrowse_these_ads
007df people_who_match:interests:Latin hip hop 185 ['839f9', '007df'] See 185 ads matching ["839f9","007df"]
60626 people_who_match:interests:Hispanidad 185 ['839f9', '60626'] See 185 ads matching ["839f9","60626"]
b1201 placements:News Feed on mobile devices 185 ['839f9', 'b1201'] See 185 ads matching ["839f9","b1201"]
cc5ed location_living_in:United States 185 ['839f9', 'cc5ed'] See 185 ads matching ["839f9","cc5ed"]
d3539 people_who_match:interests:Chicano Movement 185 ['839f9', 'd3539'] See 185 ads matching ["839f9","d3539"]
e6200 placements:News Feed on desktop computers 185 ['839f9', 'e6200'] See 185 ads matching ["839f9","e6200"]
5f10e people_who_match:interests:Mexico 183 ['839f9', '5f10e'] See 183 ads matching ["839f9","5f10e"]
4f89e people_who_match:interests:La Raza 182 ['839f9', '4f89e'] See 182 ads matching ["839f9","4f89e"]
371f0 age:18 - 65+ 181 ['839f9', '371f0'] See 181 ads matching ["839f9","371f0"]
ffca2 people_who_match:interests:Chicano rap 178 ['839f9', 'ffca2'] See 178 ads matching ["839f9","ffca2"]
4a957 people_who_match:interests:Mexican Pride 68 ['839f9', '4a957'] See 68 ads matching ["839f9","4a957"]
5849a people_who_match:interests:Mexican american culture 68 ['839f9', '5849a'] See 68 ads matching ["839f9","5849a"]
5dcb2 people_who_match:interests:Chicano 68 ['839f9', '5dcb2'] See 68 ads matching ["839f9","5dcb2"]
8b401 people_who_match:interests:Latino culture 68 ['839f9', '8b401'] See 68 ads matching ["839f9","8b401"]
eab5e people_who_match:interests:Hispanic culture 68 ['839f9', 'eab5e'] See 68 ads matching ["839f9","eab5e"]
d9d8c people_who_match:interests:Hispanic and latino american culture 66 ['839f9', 'd9d8c'] See 66 ads matching ["839f9","d9d8c"]
81cf6 people_who_match:interests:Being Chicano 28 ['839f9', '81cf6'] See 28 ads matching ["839f9","81cf6"]
68743 people_who_match:interests:Chicano rep 7 ['839f9', '68743'] See 7 ads matching ["839f9","68743"]
2ed33 excluded_connections:Exclude people who like Brown Power 3 ['839f9', '2ed33'] See 3 ads matching ["839f9","2ed33"]
59d75 language:English (US) 3 ['839f9', '59d75'] See 3 ads matching ["839f9","59d75"]
5e075 language:English (UK) 3 ['839f9', '5e075'] See 3 ads matching ["839f9","5e075"]
902e5 placements:Right column on desktop computers 3 ['839f9', '902e5'] See 3 ads matching ["839f9","902e5"]
a56e6 and_must_also_match:interests:La Raza 3 ['839f9', 'a56e6'] See 3 ads matching ["839f9","a56e6"]
d2747 language:Spanish 3 ['839f9', 'd2747'] See 3 ads matching ["839f9","d2747"]
f9d07 language:Spanish (Spain) 3 ['839f9', 'f9d07'] See 3 ads matching ["839f9","f9d07"]
4801f age:16 - 65+ 2 ['839f9', '4801f'] See 2 ads matching ["839f9","4801f"]
7b150 age:18 — 65+ 2 ['839f9', '7b150'] See 2 ads matching ["839f9","7b150"]
cea04 people_who_match:interests:Mexico Being Chicano 2 ['839f9', 'cea04'] See 2 ads matching ["839f9","cea04"]
e395d people_who_match:interests:Hispanic and latino americah culture 2 ['839f9', 'e395d'] See 2 ads matching ["839f9","e395d"]
Powered by Datasette · Query took 47.294ms