嗨,我有一个返回表(记录集)的 sql 函数
SELECT * FROM myFunction('213123');
现在我有一个查询,它给了我所有的 id
SELECT "runnerId" FROM log GROUP BY "runnerId"
我如何进行一个查询,该查询为每个“runnerId”调用该函数并将所有结果联合起来
使用cross apply
/ outer apply
as ta.speot.is说:
create function test_funct (@id int)
returns @retval table(id int not null primary key, data varchar(10))
as
begin
insert into @retval(id,data) values (@id,'test');
return ;
end;
select b.* from
(
select 1 as f1
union
select 2
)a
cross apply test_funct(a.f1) b -- or outer apply