I need to find certain data within first day of current month to the last day of current month.

```
 select count(*) from q_aggr_data as a 
       where a.filial_='fil1'
       and a.operator_ like 'unit%' 
       and date_trunc('day',a.s_end_)='"+ date_to_search+ "' 
       group by a.s_name_,date_trunc('day',a.s_end_)

```

date\_to\_searh here is 01.09.2014,02.09.2014, 03.09.2014,...,30.09.2014

I've tried to loop through i=0...30 and make 30 queries, but that takes too long and extremely naive. Also to the days where there is no entry it should return 0. I've seen how to generate date sequences, but can't get my head around on how to inject those days one by one into the query