google bigquery - SQL select unique elements and compare them on two periods -


lets have table looks this:

enter image description here

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 :

enter image description here

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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -