Say i have a table ‘users’, with ‘user_id’, ‘name’ and ‘multiplier’.
If I do a basic select, I get one row for each user:
SELECT * FROM users
What I would like to do now, is to get mutiplier rows for each user. So if I have say two users in my table which those values
(1, 'user1', 1)
(2, 'user2', 6)
What I would like to get is a select that would return me 7 rows (1 x user1 and 6 x user2)
I realize that this is very easy to do on the client side, but this will be part of a much larger query and I can’t afford to send the thousands of rows affected on the client to then multiply and sort and every other things I’m doing with it next …
Thanks to anyone that can help
I think that you’d be much better off posting the entirety of what you’re trying to solve, because there is likely a cleaner way than what you’re trying to do, but the code below should do what you need. I use a Numbers table here. You can create that as a table variable or a permanent table or a temporary table, but the idea remains the same: