home / russian-ads

russian-ads

Custom SQL query returning 36 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 199 ['4f89e', 'b1201'] See 199 ads matching ["4f89e","b1201"]
cc5ed location_living_in:United States 199 ['4f89e', 'cc5ed'] See 199 ads matching ["4f89e","cc5ed"]
e6200 placements:News Feed on desktop computers 199 ['4f89e', 'e6200'] See 199 ads matching ["4f89e","e6200"]
d3539 people_who_match:interests:Chicano Movement 198 ['4f89e', 'd3539'] See 198 ads matching ["4f89e","d3539"]
371f0 age:18 - 65+ 195 ['4f89e', '371f0'] See 195 ads matching ["4f89e","371f0"]
ffca2 people_who_match:interests:Chicano rap 185 ['4f89e', 'ffca2'] See 185 ads matching ["4f89e","ffca2"]
007df people_who_match:interests:Latin hip hop 183 ['4f89e', '007df'] See 183 ads matching ["4f89e","007df"]
60626 people_who_match:interests:Hispanidad 183 ['4f89e', '60626'] See 183 ads matching ["4f89e","60626"]
839f9 people_who_match:interests:Lowrider 182 ['4f89e', '839f9'] See 182 ads matching ["4f89e","839f9"]
5f10e people_who_match:interests:Mexico 181 ['4f89e', '5f10e'] See 181 ads matching ["4f89e","5f10e"]
4a957 people_who_match:interests:Mexican Pride 76 ['4f89e', '4a957'] See 76 ads matching ["4f89e","4a957"]
5849a people_who_match:interests:Mexican american culture 76 ['4f89e', '5849a'] See 76 ads matching ["4f89e","5849a"]
5dcb2 people_who_match:interests:Chicano 76 ['4f89e', '5dcb2'] See 76 ads matching ["4f89e","5dcb2"]
eab5e people_who_match:interests:Hispanic culture 73 ['4f89e', 'eab5e'] See 73 ads matching ["4f89e","eab5e"]
d9d8c people_who_match:interests:Hispanic and latino american culture 70 ['4f89e', 'd9d8c'] See 70 ads matching ["4f89e","d9d8c"]
8b401 people_who_match:interests:Latino culture 69 ['4f89e', '8b401'] See 69 ads matching ["4f89e","8b401"]
81cf6 people_who_match:interests:Being Chicano 29 ['4f89e', '81cf6'] See 29 ads matching ["4f89e","81cf6"]
154c2 people_who_match:interests:Culture of Mexico 11 ['4f89e', '154c2'] See 11 ads matching ["4f89e","154c2"]
68743 people_who_match:interests:Chicano rep 8 ['4f89e', '68743'] See 8 ads matching ["4f89e","68743"]
399e5 people_who_match:interests:Hispanic american culture 4 ['4f89e', '399e5'] See 4 ads matching ["4f89e","399e5"]
bb97d people_who_match:interests:Being Mexican 4 ['4f89e', 'bb97d'] See 4 ads matching ["4f89e","bb97d"]
07bd5 people_who_match:interests:Being Latino 3 ['4f89e', '07bd5'] See 3 ads matching ["4f89e","07bd5"]
694c8 people_who_match:interests:Mexican American Pride 3 ['4f89e', '694c8'] See 3 ads matching ["4f89e","694c8"]
7b150 age:18 — 65+ 3 ['4f89e', '7b150'] See 3 ads matching ["4f89e","7b150"]
cd6c0 people_who_match:interests:80 Mexican 3 ['4f89e', 'cd6c0'] See 3 ads matching ["4f89e","cd6c0"]
cea04 people_who_match:interests:Mexico Being Chicano 2 ['4f89e', 'cea04'] See 2 ads matching ["4f89e","cea04"]
e395d people_who_match:interests:Hispanic and latino americah culture 2 ['4f89e', 'e395d'] See 2 ads matching ["4f89e","e395d"]
2ed33 excluded_connections:Exclude people who like Brown Power 1 ['4f89e', '2ed33'] See 1 ads matching ["4f89e","2ed33"]
4801f age:16 - 65+ 1 ['4f89e', '4801f'] See 1 ads matching ["4f89e","4801f"]
59d75 language:English (US) 1 ['4f89e', '59d75'] See 1 ads matching ["4f89e","59d75"]
5e075 language:English (UK) 1 ['4f89e', '5e075'] See 1 ads matching ["4f89e","5e075"]
902e5 placements:Right column on desktop computers 1 ['4f89e', '902e5'] See 1 ads matching ["4f89e","902e5"]
9d28e people_who_match:interests:Hispanic: and latino american culture 1 ['4f89e', '9d28e'] See 1 ads matching ["4f89e","9d28e"]
d2747 language:Spanish 1 ['4f89e', 'd2747'] See 1 ads matching ["4f89e","d2747"]
f4a45 people_who_match:interests:Lowrideri Chicano rap 1 ['4f89e', 'f4a45'] See 1 ads matching ["4f89e","f4a45"]
f9d07 language:Spanish (Spain) 1 ['4f89e', 'f9d07'] See 1 ads matching ["4f89e","f9d07"]
Powered by Datasette · Query took 108.611ms