Skip to content

Commit 30581b1

Browse files
committed
row filter
1 parent bc5d736 commit 30581b1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/server/endpoints/covid_hosp_state_timeseries.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,13 @@ def handle():
178178
q.params["as_of"] = as_of
179179
union_subquery = f'''
180180
(
181-
SELECT *, 'D' as record_type, ROW_NUMBER() OVER (PARTITION BY date, state ORDER BY issue DESC) row_d FROM `covid_hosp_state_daily` c WHERE {cond_clause} AND row_d = 1
181+
SELECT * FROM (
182+
SELECT *, 'D' as record_type, ROW_NUMBER() OVER (PARTITION BY date, state ORDER BY issue DESC) row_d FROM `covid_hosp_state_daily` c WHERE {cond_clause}
183+
) WHERE row_d = 1
182184
UNION ALL
183-
SELECT *, 'T' as record_type, ROW_NUMBER() OVER (PARTITION BY date, state ORDER BY issue DESC) row_t FROM `covid_hosp_state_timeseries` c WHERE {cond_clause} AND row_t = 1
185+
SELECT * FROM (
186+
SELECT *, 'T' as record_type, ROW_NUMBER() OVER (PARTITION BY date, state ORDER BY issue DESC) row_t FROM `covid_hosp_state_timeseries` c WHERE {cond_clause}
187+
) WHERE row_t = 1
184188
) c'''
185189
query = f'''
186190
SELECT {q.fields_clause} FROM (

0 commit comments

Comments
 (0)