SQL Server SELECT查询中的序列行

nle07wnf  于 2023-01-16  发布在  其他
关注(0)|答案(1)|浏览(168)

我有一个简单的SELECT语句需要序列号根据结果(不需要分组或排序)我使用了Row_Number,但它需要结束。任何其他方法来做到这一点?请帮助

SELECT 
    ROW_NUMBER() OVER () AS ArrayId (:here i need sequence number)
    , TRIM(CM.Category) as Category
    , TRIM(CM.SubCategory) as SubCategory
    , CM.PlantCode
    , ISNULL(PM.PlantName,'') as PlantName
    , CM.Capacity AS Capacity_
    , CM.SizeRange
    , CM.CapacityId 
FROM capacitymaster2 CM
LEFT JOIN PlantMaster2 PM ON CM.PlantCode = PM.PlantCode
WHERE CM.SubCategory IS NOT NULL AND CM.SubCategory != ''
c0vxltue

c0vxltue1#

如果需要唯一的序列号,请尝试:ROW_NUMBER() OVER (ORDER BY (SELECT NULL)),但不关心实际顺序。

相关问题