home / russian-ads

russian-ads

Custom SQL query returning 30 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
b1201 placements:News Feed on mobile devices 188 ['ffca2', 'b1201'] See 188 ads matching ["ffca2","b1201"]
cc5ed location_living_in:United States 188 ['ffca2', 'cc5ed'] See 188 ads matching ["ffca2","cc5ed"]
d3539 people_who_match:interests:Chicano Movement 188 ['ffca2', 'd3539'] See 188 ads matching ["ffca2","d3539"]
e6200 placements:News Feed on desktop computers 188 ['ffca2', 'e6200'] See 188 ads matching ["ffca2","e6200"]
4f89e people_who_match:interests:La Raza 185 ['ffca2', '4f89e'] See 185 ads matching ["ffca2","4f89e"]
371f0 age:18 - 65+ 184 ['ffca2', '371f0'] See 184 ads matching ["ffca2","371f0"]
007df people_who_match:interests:Latin hip hop 178 ['ffca2', '007df'] See 178 ads matching ["ffca2","007df"]
60626 people_who_match:interests:Hispanidad 178 ['ffca2', '60626'] See 178 ads matching ["ffca2","60626"]
839f9 people_who_match:interests:Lowrider 178 ['ffca2', '839f9'] See 178 ads matching ["ffca2","839f9"]
5f10e people_who_match:interests:Mexico 176 ['ffca2', '5f10e'] See 176 ads matching ["ffca2","5f10e"]
4a957 people_who_match:interests:Mexican Pride 64 ['ffca2', '4a957'] See 64 ads matching ["ffca2","4a957"]
5849a people_who_match:interests:Mexican american culture 64 ['ffca2', '5849a'] See 64 ads matching ["ffca2","5849a"]
5dcb2 people_who_match:interests:Chicano 64 ['ffca2', '5dcb2'] See 64 ads matching ["ffca2","5dcb2"]
eab5e people_who_match:interests:Hispanic culture 64 ['ffca2', 'eab5e'] See 64 ads matching ["ffca2","eab5e"]
d9d8c people_who_match:interests:Hispanic and latino american culture 62 ['ffca2', 'd9d8c'] See 62 ads matching ["ffca2","d9d8c"]
8b401 people_who_match:interests:Latino culture 61 ['ffca2', '8b401'] See 61 ads matching ["ffca2","8b401"]
81cf6 people_who_match:interests:Being Chicano 28 ['ffca2', '81cf6'] See 28 ads matching ["ffca2","81cf6"]
154c2 people_who_match:interests:Culture of Mexico 10 ['ffca2', '154c2'] See 10 ads matching ["ffca2","154c2"]
2ed33 excluded_connections:Exclude people who like Brown Power 3 ['ffca2', '2ed33'] See 3 ads matching ["ffca2","2ed33"]
59d75 language:English (US) 3 ['ffca2', '59d75'] See 3 ads matching ["ffca2","59d75"]
5e075 language:English (UK) 3 ['ffca2', '5e075'] See 3 ads matching ["ffca2","5e075"]
902e5 placements:Right column on desktop computers 3 ['ffca2', '902e5'] See 3 ads matching ["ffca2","902e5"]
a56e6 and_must_also_match:interests:La Raza 3 ['ffca2', 'a56e6'] See 3 ads matching ["ffca2","a56e6"]
bb97d people_who_match:interests:Being Mexican 3 ['ffca2', 'bb97d'] See 3 ads matching ["ffca2","bb97d"]
d2747 language:Spanish 3 ['ffca2', 'd2747'] See 3 ads matching ["ffca2","d2747"]
f9d07 language:Spanish (Spain) 3 ['ffca2', 'f9d07'] See 3 ads matching ["ffca2","f9d07"]
4801f age:16 - 65+ 2 ['ffca2', '4801f'] See 2 ads matching ["ffca2","4801f"]
7b150 age:18 — 65+ 2 ['ffca2', '7b150'] See 2 ads matching ["ffca2","7b150"]
cea04 people_who_match:interests:Mexico Being Chicano 2 ['ffca2', 'cea04'] See 2 ads matching ["ffca2","cea04"]
e395d people_who_match:interests:Hispanic and latino americah culture 2 ['ffca2', 'e395d'] See 2 ads matching ["ffca2","e395d"]
Powered by Datasette · Query took 67.852ms