这与WadimX的答案有完全相同的限制,但是它将执行100行。在给定输入表的情况下生成示例输出(我将其称为
example):
;WITH nums AS (SELECt 1 AS RowNum, Name, Amount FROM (SELECt Name, Amount FROM example) s UNIOn ALL SELECt RowNum + 1 As RowNum, Name, CAST(1.1*Amount AS INT) AS Amount FROM nums WHERe RowNum < 5) SELECt RowNum AS SNo, Name, AmountFROM nums ORDER BY Name
SQLFiddle
这将为中的每个记录返回5行
example,您可以通过更改
RowNum < 5为
100或更改为任意数量来增加计数。
输出
SNo Name Amount-----------------------1 A 12002 A 13203 A 1452... ... ...
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)