google bigquery - SQL select unique elements and compare them on two periods -
lets have table looks this:
i want able see how many url records there during period1 , period2.
where period 1 "date > '2016-01-01' , date < '2017-01-01' "
and period 2 "date > '2014-01-1' , date < '2015-01-01' "
here visualization of expectations :
i can 1 single period using following query:
select url, count(url) period1 table date < '2017-01-01' , date > '2016-01-01' group url
but how add second column period2?
any thoughts appreciated. sorry if explained myself incorrectly.
for bigquery standard sql
#standardsql select url uri, countif(date between '2016-01-01' , '2016-12-31') period1, countif(date between '2014-01-01' , '2014-12-31') period2 `logfilesv2_dataset.de_visits` group url
Comments
Post a Comment