我有一个Oracle select需要在SQL Server中执行(表从Oracle数据库导出到SQL Server数据库)。我可以将nvl
替换为isnull
,并使用case进行解码,但如何在此特定情况下处理rowid
?
select sum(
nvl(
(select sum(b.restsaldo) from reskontro.erkrysskid b
where 1=1
and b.fakturanr = a.fakturanr
and b.kundenr = a.kundenr
and b.resknr = b.resknr
and a.rowid = decode(a.reskfunknr,31,a.rowid,b.rowid)
and nvl(b.restsaldo,0) <> 0
and b.krysskidid <= a.krysskidid
and not exists (select * from reskontro.erkrysskid c
where b.kundenr = c.kundenr
and b.resknr = c.resknr
and a.resklinr < c.resklinr
and a.krysskidid < c.krysskidid
and b.fakturanr = c.fakturanr
and c.reskfunknr in (31,75)
and nvl(c.attfort,-1) = -1)
),0
)
) as restsaldo from reskontro.erkrysskid a
where 1=1
and a.kundenr = 1
and a.resknr = 1
1条答案
按热度按时间but5z9lq1#
SQL Server没有ROWID伪列。在Oracle中,ROWID伪列用于自联接的上下文中,以确定要联接的两行是否为“同一行”。在SQL Server中,只需比较表的键列即可。
例如,如果表在Id列上有键,则使用