I have a table like this:
|---------|-----|
| Name | Qty |
|---------|-----|
| Joe | 3 |
| Bill | 2 |
| Mike | 4 |
|---------|-----|
I am trying to create a SELECT
statement that will return this:
|--------|
| Name |
|--------|
| Joe |
| Joe |
| Joe |
| Bill |
| Bill |
| Mike |
| Mike |
| Mike |
| Mike |
|--------|
Basically, whatever the Qty
field is set to is how many times the Name
is returned. I found a very similar question here, but this question is for Oracle and I'm using SQL Server. I also would prefer to do this in a SELECT
statement (because it'll later be used in a view) rather than having to use temp tables or cursors.