Scenario: I have 1 columns in my select statement; Name which I want to repeat based on the value of a calculated field named Number calculated using a case statement like this
Case when number<0.95 then 0
when number>=1 then 10…. END AS Number.
Example Jim W has a Number value of 6 so I want the SQL statement to return 6 rows with the Name of Jim W.
Name
JIM W
JIM W
JIM W
JIM W
JIM W
JIM W
Other points to note is that it should group by a column named region and its SQL Server 2008.
Is this possible?
Thanks
try this:
The easiest way to do this in sql server is to join with the system table master..spt_values
provided your number of repetition for each name should be less than 2048
SQL Fiddle Demo