This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH bicycle_rentals AS ( | |
SELECT | |
COUNT(starttime) as num_trips, | |
EXTRACT(DATE from starttime) as trip_date | |
FROM `bigquery-public-data.new_york_citibike.citibike_trips` | |
GROUP BY trip_date | |
), | |
rainy_days AS | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
my_drug_list ARRAY<STRING>; | |
SET | |
my_drug_list = [ 'Premarin', | |
'Calcium disodium versenate', | |
'Keytruda', | |
'Vioxx', | |
'Humira' ]; | |
SELECT | |
id AS drug_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
associations.targetId AS target_id, | |
targets.approvedSymbol AS target_approved_symbol, | |
associations.diseaseId AS disease_id, | |
diseases.name AS disease_name, | |
associations.score AS overall_association_score | |
FROM | |
`open-targets-prod.platform.associationByOverallDirect` AS associations | |
JOIN | |
`open-targets-prod.platform.diseases` AS diseases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
game_clock, | |
SUM( | |
CASE | |
WHEN team_name = 'Wildcats' THEN points_scored | |
END | |
) OVER(ORDER BY timestamp ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS wildcats_score, | |
SUM( | |
CASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH quantiles AS ( | |
SELECT APPROX_QUANTILES(LOG10(latency), 50) AS timearray | |
FROM `cloud-datalab-samples.httplogs.logs_20140615` | |
WHERE latency <> 0 | |
) | |
select row_number() over(order by time) as percentile, time from quantiles cross join unnest(quantiles.timearray) as time | |
order by percentile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
genex.case_barcode AS case_barcode, | |
genex.sample_barcode AS sample_barcode, | |
genex.aliquot_barcode AS aliquot_barcode, | |
genex.HGNC_gene_symbol AS HGNC_gene_symbol, | |
clinical_info.Variant_Type AS Variant_Type, | |
genex.gene_id AS gene_id, | |
genex.normalized_count AS normalized_count, | |
genex.project_short_name AS project_short_name, | |
clinical_info.demo__gender AS gender, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
case_list.case_barcode AS case_barcode, | |
case_list.Variant_Type AS Variant_Type, | |
clinical.demo__gender, | |
clinical.demo__vital_status, | |
clinical.demo__days_to_death | |
FROM | |
/* this will get the unique list of cases having the TP53 gene mutation in BRCA cases*/ | |
( SELECT | |
mutation.case_barcode, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
age.country_name, | |
SUM(age.population) AS under_25, | |
pop.midyear_population AS total, | |
ROUND((SUM(age.population) / pop.midyear_population) * 100,2) AS pct_under_25 | |
FROM ( | |
SELECT country_name, population, country_code | |
FROM `bigquery-public-data.census_bureau_international.midyear_population_agespecific` | |
WHERE year =2017 AND age < 25) age | |
INNER JOIN ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'board') AS board_type, | |
AVG((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'value')) AS avg_score | |
FROM `firebase-public-project.analytics_153293282.events_20180915` | |
WHERE event_name = "level_complete_quickplay" | |
GROUP BY board_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH analytics_data AS ( | |
SELECT user_pseudo_id, event_timestamp, event_name, | |
app_info.version AS app_version, -- This is new! | |
UNIX_MICROS(TIMESTAMP("2018-09-01 00:00:00", "+8:00")) AS start_day, | |
3600*1000*1000*24*7 AS one_week_micros | |
FROM `firebase-public-project.analytics_153293282.events_*` | |
WHERE _table_suffix BETWEEN '20180901' AND '20180930' | |
) | |
SELECT week_0_cohort / week_0_cohort AS week_0_pct, |
NewerOlder