home / russian-ads

russian-ads

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