postgresql - Redshift count number of Mondays in a given time range -


i want use redshift count number of mondays in given time range. i've tried using date_part, returns day of week. can't use simple count there multiple instances on same day.

if have dates table reference can use following code

select count(distinct my_table.date) my_table  date_part(dow,my_table.date)=1 , my_table.date between '2015-01-01' , '2016-01-01' 

in case query count mondays during 2015,

you can change dates range the day week .

date_part(dow,my_table.date)=1 -- monday date_part(dow,my_table.date)=2 -- tuesday 

and on

if don't have dates table , should create cartesian product


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -