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 |
Saurabh008
Starting Member
1 Post |
Posted - 2013-11-11 : 12:37:45
|
Hi, I need your suggestions in realising the following requirement. I have a table with 1.3Million records and I need to determine column 'Contribution 2' for each of these 1.3Millions records. My data looks like this - Material Number Sales Contribution 1 (%) Contribution 2 ClassC2 150 34.88% 34.88% AC3 120 27.91% 62.79% AC1 100 23.26% 86.05% BC4 35 8.14% 94.19% BC5 25 5.81% 100.00% CTotal 430 100.00% The table has the following columns - Material, Sales, Contribution 1 (%) (sale of each Material expressed as a % of the Total Sales), Contribution 2 ( for each record, sum of all values less than it), Class (determined from Contribution 2)A brief about Contribution 2 column - its the sum total of all Contribution 1 values. For example: for material C3 Contribution 2 = Contri 1 of c3 + contri 1 of c2. Similarly for material C1 Contribution 2 = Contri 1 of c3 + contri 1 of c2 + contri 1 of c1. and so on for each material.I am currently doing this as a self-join of the table. Am really not happy with the performance - its taking ~14 mins to process this. Have also tried partitioning the table but to no avail. I do not wish to use loops here. Would appreciate if you could advise on doing this better as i need to scale it to 50 million records |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-11 : 12:43:30
|
is there any column which will determine th order for you? otherwise you cant determine which all material comes before current one. There's no concept of order in sql table unless you specify it in terms of a column using ORDER BY. So ideally you need a unique valued column (date field, id column etc)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|