Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
notmyrealname
98 Posts |
Posted - 2010-08-31 : 10:11:24
|
Hi,Does anyone know if it is possible to (using a SELECT query) to return multiple rows for rows with a Quantity > 1?For example...Part: Qtya1: 3a2: 1a3: 6...would return...Parta1a1a1a2a3a3a3a3a3a3I would like to return individual rows for the total Qty of each part. I would love to do this in a single query but i am doubtful that it is possible.Any ideas?Thanks,Joel |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-31 : 10:26:38
|
select part from your_table as t1cross join master..spt_values as t2where qty<=t2.number and type='0' MadhivananFailing to plan is Planning to fail |
 |
|
notmyrealname
98 Posts |
Posted - 2010-08-31 : 11:42:49
|
Hey Madhivanan,You rock! I don't care what everyone else says about you. I like how you teach a man to fish. I scratched my head for a bit looking at your solution but after a little reseach on the spt_values table i finally figured out what you were doing. Makes perfect sense now.I did tweak it a bit by adding my own NumberList table to join against because i do have Qty values into the thousands.Thanks a ton for the tip.Joel |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-01 : 05:06:11
|
quote: Originally posted by notmyrealname Hey Madhivanan,You rock! I don't care what everyone else says about you. I like how you teach a man to fish. I scratched my head for a bit looking at your solution but after a little reseach on the spt_values table i finally figured out what you were doing. Makes perfect sense now.I did tweak it a bit by adding my own NumberList table to join against because i do have Qty values into the thousands.Thanks a ton for the tip.Joel
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|