私はpostgresのクロス集計関数にテキストを渡す必要があることを知っています。しかし、どういうわけか私はそれをすることができません。何が間違っているのか分かりません。これは私がクロス集計関数postgresで引数を渡すことができません
create or replace function hrms.test2(startdate date)
returns table(
employeeid int,
col1 int,
col2 INT,
col3 int,
col4 int) as
$body$
SELECT * FROM hrms.crosstab(
$firstquery$
SELECT tms.employeeid,tms.today,count(tms.employeeid) as countid
FROM hrms.timesheet as tms
where dated>=|| quote_literal(startdate) ||
and dated < ||+ quote_literal(startdate)||::timestamp + '1 MONTH'::INTERVAL
group by tms.employeeid,tms.today $firstquery$,
$secquery$ select distinct tms.today
from hrms.timesheet as tms$secquery$
)as
finalresult(employeeid int,leave int,present int,absent int, holiday int)
$body$
LANGUAGE SQL;
それが正常に実行を作成しようとしています機能ですが、私はそれが
select * from hrms.test2('2017-09-01')
のように日付を使用して実行すると、私は
column startdate doesn't exist
は私が持っているというエラーメッセージが表示されます同様にいくつかの選択肢を試しました。私は何が間違っているのか分からない。
は、誰もがの2行目に+記号を削除した後、それが働いた少なくとも – Vikram