CREATE PROCEDURE [dbo].[FlowClientGetNum]
(@ID_ListGroupParIzm Integer, @ID_ListParIzm Integer)
AS
SELECT
Number of my @ID_ListParIzm FROM -- sure this string doesn't works --
SELECT
C.ID_ListParIzm,
FROM
CfgListParIzm C
WHERE
C.ID_ListGroupParIzm = @ID_ListGroupParIzm AND
C.VisibleOnTab=1
ORDER BY C.Num
如何从select中获取节点数ID_ListParIzm = @ ID_ListParIzm?
例如我从select
获得2
7
8
2
4
68
96
2
3
我的价值是8。 程序必须返回3.(数量为8)
谢谢
答案 0 :(得分:1)
鉴于您有ORDER BY,您可以查看使用ROW_NUMBER。
像
这样的东西SELECT RowNumber
FROM (
SELECT
C.ID_ListParIzm,
ROW_NUMBER() OVER(ORDER BY C.Num) RowNumber
FROM
@CfgListParIzm C
WHERE
C.ID_ListGroupParIzm = @ID_ListGroupParIzm AND
C.VisibleOnTab=1
) sub
WHERE ID_ListParIzm = @ID_ListParIzm