--> 测试数据:[TB]
if object_id('[TB]') is not null drop table [TB]
GO
create table [TB]([Id] int,[ProductName] varchar(7),[SumCout] int)
insert [TB]
select 1,'iPad2',2 union all
select 2,'iPhone5',3
select t.[Id],t.[ProductName],[Count]=1 from [TB] t INNER JOIN [master].dbo.spt_values sv on t.SumCout>sv.number
WHERE sv.[type]='p'
/*
Id ProductName Count
----------- ----------- -----------
1 iPad2 1
1 iPad2 1
2 iPhone5 1
2 iPhone5 1
2 iPhone5 1
(5 行受影响)
http://bbs.csdn.net/topics/390300565点击打开链接