select
u_id,
case
when work_start > '2012-12-01'::date then work_start
else '2012-12-01'::date
end::date + generate_series(1, 31) - 1 as ndate
from n_users
where
u_id = 300
4 sty 2013
select
u_id,
case
when work_start > '2012-12-01'::date then work_start
else '2012-12-01'::date
end::date + generate_series(1, 31) - 1 as ndate
from n_users
where
u_id = 300