使用
tally table
WITH lv0 AS (SELECt 0 g UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0 UNIOn ALL SELECT 0) ,lv1 AS (SELECT 0 g FROM lv0 a CROSS JOIN lv0 b) --10 * 10 = 100 ,lv2 AS (SELECt 0 g FROM lv1 a CROSS JOIN lv0 b) --100 * 10 = 1000 ,Tally (num) AS (SELECt ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM lv2) SELECt (num+StartNo-1) as TicketNo, * FROM TallyCROSS JOIN Yourtable WHERe num <= booksize ORDER BY book
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)