1 CREATE TABLE#t1 (2Plantnovarchar(4),3Vendorcodevarchar(Ten),4Amountdecimal( -,2))5 6 Insert#t1Values('P112','1',Ten)7 Insert#t1Values('P112','2', -)8 Insert#t1Values('P112','3', -)9 Insert#t1Values('P112','4', +)Ten Insert#t1Values('P115','1',Ten) One A Select#t1. Plantno,vendorcode,amount,amount asAmounttotal,amount asAmounttotal2,amount as Rate - into#t2 - from#t1Order byPlantno,amountdesc the - Update#t2SetAmounttotal=(Select SUM(amount) from#t1where#t1. Plantno=#t2. PLANTNO) - Update#t2SetAmountTotal2=(Select SUM(amount) from#t1where#t1. Plantno=#t2. Plantno andAmount>=#t2. Amount) - Update#t2SetRate=AmountTotal2/Amounttotal + Select * from#t2 - Drop Table#t1 + Drop Table#t2 A at --Results - plantno vendorcode amount Amounttotal amountTotal2 rate -P1124 40.00 100.00 40.00 0.40 -P1123 30.00 100.00 70.00 0.70 -P1122 20.00 100.00 90.00 0.90 -P1121 10.00 100.00 100.00 1.00 inP1151 10.00 10.00 10.00 1.00
This part of the program is designed to be a few of the most exhausting problems. For example: The richest man accounted for 2%, the second accounted for 1.5%, so the first 2 were 3.5%.
Ratio of fatigue