[英]Outer apply to left join conversion
I have a query in SQL Server that I'm trying to migrate to redshift.我在试图迁移到 redshift 的 SQL 服务器中有一个查询。 It has OUTER APPLY
in it but Redshift doesn't support it.它有外部应用,但OUTER APPLY
不支持它。 How can I convert it to left join
so that I can use it in Redshift?如何将它转换为left join
以便我可以在 Redshift 中使用它?
....
OUTER APPLY
(
SELECT TOP 1 fel.*
FROM fact.FactEventLog fel
WHERE fpt.ParcelProfileKey = fel.ParcelProfileKey
AND
fpt.LastEventKey = fel.EventLegKey
AND
FPT.DateLastEvent = fel.EventDateTimeUTC
) fel
....
Something answered in this stackoverflow or this answer在此 stackoverflow或此答案中回答了一些问题
Maybe.... someting like...也许……有点像……
....
LEFT JOIN
(
SELECT fel.*, row_number() over (partition by ParcelProfileKey, EventLegKey, EventDateTimeUTC order by null) RN
FROM fact.FactEventLog fel
) fel
on fpt.ParcelProfileKey = fel.ParcelProfileKey
AND fpt.LastEventKey = fel.EventLegKey
AND fpt.DateLastEvent = fel.EventDateTimeUTC
AND 1=fel.RN
....
but it just seems so wrong w/o an order by actually defined in the window function. it's like you don't care what random result is returned just so long as 1 exists... but then why not use an exists.... shrug但是如果没有在 window function 中实际定义的顺序,这似乎是错误的。就像你不关心返回什么随机结果一样,只要 1 存在...但是为什么不使用存在... .耸肩
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.