我正在尝试使用“WITH”,它是 PostgreSQL 函数中的公共表表达式。
以下是示例:
Example:
Create or replace function withFunction() returns void as
$Body$
Begin
WITH cmn_l1
AS
(
SELECT "PhoneNumber1","PhoneNumber2",
DENSE_RANK() OVER(Partition by "PhoneNumber1" Order By "PhoneNumber2" )FoundIn
From tablename;
)
SELECT DISTINCT * INTO temptable
FROM cmn_l1
WHERE FoundIn > 1;
end;
$Body$
language plpgsql;
Question:如何在函数内使用WITH执行并获取上表中的值?
是否需要返回table
Create or replace function withFunction()
returns table(phone1 text, phone2 text) as
then
select * from withFunction()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)