title: pass parameters in crosstab query postgres
body: <p>How to pass a parameter in <code>crosstab</code> query in <code>postgresql</code>.
  Please refer the below function in postgresql</p>
  
  <pre><code>create function sp_nextfollowup_count_byweek(_from timestamp without time zone,_to timestamp without time zone)
  returns table(userid integer,username character varying,day1 bigint,day2 bigint,day3 bigint,day4 bigint,day5 bigint,day6 bigint,day7 bigint)as
  $BODY$
  BEGIN
  return query
  with cte as(
  select * from crosstab($$
  select  follow_up_by,next_follow_up_date,count(*) from sales_enquiry_follow_up where next_follow_up_date between _from and _to
  group by follow_up_by,next_follow_up_date 
  order by follow_up_by,next_follow_up_date$$,$$select date::timestamp without time zone
  from generate_series(
    _from,
    _to,
    '1 day'::interval
  ) date$$)
  as(id integer, dd bigint,dd1 bigint,dd2 bigint,dd3 bigint,dd4 bigint,dd5 bigint,dd6 bigint)
  )
  select cte.id,u.username,cte.dd,cte.dd1,cte.dd2,cte.dd3,cte.dd4,cte.dd5,cte.dd6 from cte left join users u on cte.id=u.id;
  
  END;
  $BODY$
  language plpgsql;
  </code></pre>
  
  <p>I am getting this error <code>column "_from" does not exist</code>. How to solve this issue?</p>