ネットで検索されていて、CTEのないウィンドウ関数を含むクエリを作成しようとしましたが、結果を得ることができず、いくつかの助けが必要です 私は私がやっている必要なものCTEを作成し、1つのクエリでCTEなしで1つのクエリでウィンドウ関数を適用する
;with cte(Gid, id, prod, orderdate, shipdate, ranking) as
(
select
p1.Gid Gid,
p1.id id,
p1.prod prod,
p1.orderdate orderdate,
p2.shipdate shipdate,
rank() over (partition by p1.prod order by p1.id desc) ranking
from
shpro p1
inner join
shpro p2 on p1.id = p2.id
where
cast(p1.orderdate as DATE) > GETDATE()
and cast(p1.shipdate as DATE) < GETDATE() - 1
)
select *
from cte
where ranking = 1
CTEを使用する際の問題点は何ですか?なぜCTEを避けようとしていますか? –