0
我需要按照dateshipped
的顺序设置项目,但是在CTE中间。 我使用窗口函数来设置项目的顺序(因为我不能使用顺序)。MSSQL窗口函数
select ROW_NUMBER() over(partition by [sku] order by [dateshipped] desc) as [rows]
,[sku]
,[dateshipped]
,[priceperunit]
from [Order Details]
我遇到的问题是当dateshipped
是空的行编号而不是分配给该项目。
当dateshipped
为空时,我将如何获得指定的行号?
这是不正确的。当'dateshipped'为'null'时,它们将首先在分区中排序。 (对不起,因为你有'desc'方向)。 [SQL小提琴](http://sqlfiddle.com/#!3/d41d8/29748) –