SQL: Repeat a result row multiple times, and number the rows

You could use a numbers table

SELECT value, count, number
FROM table
    JOIN Numbers 
        ON table.count >= Numbers.number

Here is a SQLFiddle using MSSQL

Leave a Comment