Skip to content

Instantly share code, notes, and snippets.

@preetamtt
Created April 18, 2018 01:01
Show Gist options
  • Save preetamtt/8e6702ceceb0b96093cf4634b19118b3 to your computer and use it in GitHub Desktop.
Save preetamtt/8e6702ceceb0b96093cf4634b19118b3 to your computer and use it in GitHub Desktop.
WITH clicks AS (
SELECT ir.*, service_page_viewed as clicked
FROM `sandbox.ir_ranking_training_ds_apr17_18` ir
INNER JOIN `instant_results.search_results` s ON CAST(ir.service_pk AS INT64) = s.service_pk AND CAST(ir.search_request_pk as INT64) = s.search_request_pk
),
search_atleast_one_quote AS (
SELECT search_request_pk, COUNTIF(quote_pk IS NOT NULL) as num_quotes
FROM clicks
GROUP BY 1
HAVING num_quotes > 0
)
SELECT COUNT(DISTINCT search_request_pk) FROM search_atleast_one_quote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment