如何获取所选节点的数量

时间:2010-03-11 11:41:17

标签: sql

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)

谢谢

1 个答案:

答案 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