如何根据数量获取表的TagNo

时间:2022-03-30 07:20:42

I Have a Table with 2 items in that 1 item has 3 quantity and other item have 2 i need to get it like for item 1-1,2,3(3quantity) and item 2-1,2(2quantity)

我有一个表有2个项目,1个项目有3个数量,其他项目有2我需要得到它像项目1-1,2,3(3quantity)和项目2-1,2(2quantity)

ItemName Quantity TagNo
Cap       3        1
Cap       3        2
Cap       3        3
Shirt     2        1
Shirt     2        2

2 个解决方案

#1


0  

Please try

请尝试

SELECT itemname
    ,quantity
    ,row_number() OVER (
        PARTITION BY itemname ORDER BY itemname
        )
FROM < table_name >;

#2


0  

I think you should output to be like that ? :

我想你应该输出那样的? :

如何根据数量获取表的TagNo

Then fire below SQL Command :

然后在SQL命令下面触发:

SELECT ItemName
    ,Quantity
    ,row_number() OVER (
        PARTITION BY ItemName
        ,Quantity ORDER BY Quantity
        ) QuantitySR
    ,TagNo
FROM YourTableName

#1


0  

Please try

请尝试

SELECT itemname
    ,quantity
    ,row_number() OVER (
        PARTITION BY itemname ORDER BY itemname
        )
FROM < table_name >;

#2


0  

I think you should output to be like that ? :

我想你应该输出那样的? :

如何根据数量获取表的TagNo

Then fire below SQL Command :

然后在SQL命令下面触发:

SELECT ItemName
    ,Quantity
    ,row_number() OVER (
        PARTITION BY ItemName
        ,Quantity ORDER BY Quantity
        ) QuantitySR
    ,TagNo
FROM YourTableName