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 |
|
usenthil75
Starting Member
4 Posts |
Posted - 2008-05-20 : 01:58:35
|
| i want to split the value of one column into multiple rows. based on comp capacity. pl help me in writing queryActual table Product Id ProductQty CompCapacity1 8000 50002 10000 5000 4000 4000Resultant table Product Id ProductQty CompCapacity2 5000 50002 5000 50001 4000 40001 4000 4000 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-20 : 02:06:40
|
| Your sample data is not clear. WHy 4000 does not have a ProductId? Also why have you split 800 into two 4000 while value for CompCapacity is 5000? Please specify your business rules. |
 |
|
|
usenthil75
Starting Member
4 Posts |
Posted - 2008-05-20 : 05:44:58
|
| Product Qty is order qty. Truck Available with different capacities. I have to match order qty to Truck capacity. You can take truck no as reference on which the record set to be updated |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-20 : 05:48:24
|
quote: Originally posted by usenthil75 Product Qty is order qty. Truck Available with different capacities. I have to match order qty to Truck capacity. You can take truck no as reference on which the record set to be updated
Truck no?I cant see such a field in your sample data. Can post your fll table structure plzz? |
 |
|
|
usenthil75
Starting Member
4 Posts |
Posted - 2008-05-20 : 05:53:50
|
| Actual table Truck No Product Id ProductQty CompCapacityKA01A555 1 8000 5000KA01A555 2 10000 5000KA01A555 4000KA01A555 4000 Resultant table Truck No Product Id ProductQty CompCapacityKA01A555 2 5000 5000KA01A555 2 5000 5000KA01A555 1 4000 4000KA01A555 1 4000 4000 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-20 : 05:56:45
|
quote: Originally posted by usenthil75 Actual table Truck No Product Id ProductQty CompCapacityKA01A555 1 8000 5000KA01A555 2 10000 5000KA01A555 4000KA01A555 4000 Resultant table Truck No Product Id ProductQty CompCapacityKA01A555 2 5000 5000KA01A555 2 5000 5000KA01A555 1 4000 4000KA01A555 1 4000 4000
How do you decide that 4000 actually corresponds to record with ProductId 1? |
 |
|
|
usenthil75
Starting Member
4 Posts |
Posted - 2008-05-20 : 06:11:16
|
| select compartment sum of compcapacity = productqty and then split the product qty and assign against compcapacity |
 |
|
|
|
|
|