I am trying to use this query from here - http://technoir.blog/blog/post/timeseries_tips_for_postgresql:
with filled_dates as (
select day, 0 as blank_count from
generate_series('2014-01-01 00:00'::timestamptz, current_date::timestamptz, '1 day')
as day
),
signup_counts as (
select date_trunc('day', created_at) as day, count(*) as signups
from users
group by date_trunc('day', created_at)
)
select filled_dates.day,
coalesce(signup_counts.signups, filled_dates.blank_count) as signups
from filled_dates
left outer join signup_counts on signup_counts.day = filled_dates.day
order by filled_dates.day
When I put this in @Query("WITH filled_dates as ( .... "), it throws this error -
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: WITH near line 1, column 1 [WITH filled_dates as
How can I use WITH clause in manual JPA queries?