我有一个查询作为下面的示例,但它永远运行..如果执行联合,则我复制了整个大型查询..此修复程序的任何帮助
select columns
from table a
join (select *
from ( select *, row_number() over( partition BY id ORDER BY date ) row_seq
from table b
) where row_seq = 1
) o ON a.id = o.id OR a.id = o.src_id
left join table p on a.partner_c = p.id
left join table pp on a.parnt_id = pp.id
内部
can be written using the QUALIFY clause like so:
可以将其推送到CTE中,例如:
which means you can union that whole thing or just the
table a
andraw_rows o
but this will give you a slightly different result if
o.src_id == o.id
for any row, as it will match both verse the OR vesion will have those lines once. You can pay the GROUP BY cost by swapping to UNION to de-dup, but then if you have many lines you want to keep those will be lost. Or you can change second half of the union to not included those line with取决于您的数据和需求。