title: using WITH clause in @Query JPA Postgresql
body: <p>I am trying to use this query from here - <a href="http://technoir.blog/blog/post/timeseries_tips_for_postgresql" rel="nofollow noreferrer">http://technoir.blog/blog/post/timeseries_tips_for_postgresql</a>: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>When I put this in <code>@Query("WITH filled_dates as ( .... ")</code>, it throws this error - </p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: WITH near line 1, column 1 [WITH filled_dates as
  </code></pre>
  
  <p>How can I use WITH clause in manual JPA queries?</p>