哪个 SQL 函数可以替代 SQL 中 Informatica 的 FIRST()?
Which SQL function can be used as alternative of FIRST() of Informatica in SQL?
您好,我正在尝试将 Informatica 聚合器转换转换为 SQL 查询,但我一直在寻找 FIRST() Informatica 函数的替代方法 [=19] =] 用于以下查询:
Select emp.*,
first_value(ename)over (order by empid) ename1,
first_value(ehobby)over (order by empid) ehobby1
From emp;
此查询为所有记录提供第一行,但我想按 empid 对其进行分组。任何人都可以请建议吗?
Select empid,
(select top 1 ISNULL(ename,'') from emp where ename=obj.ename order by empid) as ename1
(select top 1 ISNULL(ehobby,'') from emp where ehobby=obj.ehobby order by empid) as ehobby1
From emp as obj
group by obj.empid,obj.ename1,obj.ehobby1
我已经尝试过上面的查询,请检查这可能有帮助,对于分组依据,你必须 select 一列名称
如有错误请见谅
我是 Whosebug 的新手。
This query is giving first row for all records but I want to group it by empid.
我希望 empid
在名为 emp
的 table 中成为 distinct
。但是,如果您有多行并且想要第一个值,那么您需要一个排序列。让我假设你有一个。在这种情况下:
select emp.*,
first_value(ename) over (partition by empid order by <ordering col>) as ename1,
first_value(ehobby) over (partition by empid order by <ordering col>) as ehobby1
from emp;
您好,我正在尝试将 Informatica 聚合器转换转换为 SQL 查询,但我一直在寻找 FIRST() Informatica 函数的替代方法 [=19] =] 用于以下查询:
Select emp.*,
first_value(ename)over (order by empid) ename1,
first_value(ehobby)over (order by empid) ehobby1
From emp;
此查询为所有记录提供第一行,但我想按 empid 对其进行分组。任何人都可以请建议吗?
Select empid,
(select top 1 ISNULL(ename,'') from emp where ename=obj.ename order by empid) as ename1
(select top 1 ISNULL(ehobby,'') from emp where ehobby=obj.ehobby order by empid) as ehobby1
From emp as obj
group by obj.empid,obj.ename1,obj.ehobby1
我已经尝试过上面的查询,请检查这可能有帮助,对于分组依据,你必须 select 一列名称 如有错误请见谅 我是 Whosebug 的新手。
This query is giving first row for all records but I want to group it by empid.
我希望 empid
在名为 emp
的 table 中成为 distinct
。但是,如果您有多行并且想要第一个值,那么您需要一个排序列。让我假设你有一个。在这种情况下:
select emp.*,
first_value(ename) over (partition by empid order by <ordering col>) as ename1,
first_value(ehobby) over (partition by empid order by <ordering col>) as ehobby1
from emp;