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 |
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2012-03-01 : 09:55:18
|
| Hi, I have 2 tablesTblTempz1 z2 z3 z40.20 0.30 0.40 0.50TblBusTypeC1 C2 C3 C4A 1 2 3 4B 2 3 4 5C 3 4 5 6D 4 5 6 7Now, I need to compute the following; (A/B) z1 x (A/B) z2 x (A/B) z3 x (A/B) z4 as result1(A/C) z1 x (A/C) z2 x (A/C) z3 x (A/C) z4 as result2(A/D) z1 x (A/D) z2 x (A/D) z3 x (A/D) z4 as result3(B/C) z1 x (B/C) z2x (B/C) z3 x (B/C) z4 as result4(B/D) z1 x (B/D) z2x (B/D) z3 x (B/D) z4 as result5(C/D) z1 x (C/D z2 x (C/D) z3 x (C/D) z4 as result6the above can also be represented with values as(1/2)0.20 x (2/3)0.30 x (3/4)0.40 x (4/5)0.50 as result1(1/3)0.20 x (2/4)0.30 x (3/5)0.40 x (4/6)0.50 as result2(1/4)0.20 x (2/5)0.30 x (3/6)0.40 x (4/7)0.50 as result3(2/3)0.20 x (3/4)0.30 x (4/5)0.40 x (5/6)0.50 as result4(2/4)0.20 x (3/5)0.30 x (4/6)0.40 x (5/7)0.50 as result5(3/4)0.20 x (4/5)0.30 x (5/6)0.40 x (6/7)0.50 as result6N/B: (A/B) z1 is supposed to be (A/B)to the power z1 and so on for the rest of the query. Couldn't do it here...Note: This particular example is based on 4 records A, B, C & D. I will want to do it for nearly 200 combinations. Therefore, the query should accomodate more records. Thank you very much |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2012-03-01 : 10:39:07
|
| TblBusTypeBusType C1 C2 C3 C4A 1 2 3 4B 2 3 4 5C 3 4 5 6D 4 5 6 7A,B,C & D are Business types with 4 criterias each.Tbltemp has only one row with 4 fields. thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-01 : 10:47:37
|
sounds like thisSELECT (bt1.C1*1.0/bt2.C1)*t.z1 * (bt1.C2*1.0/bt2.C2)*t.z2 * (bt1.C3*1.0/bt2.C3)*t.z3 * (bt1.C4*1.0/bt2.C4)*t.z4FROM TblBusType bt1CROSS JOIN TblBusType bt2CROSS JOIN TblTemp t ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2012-03-01 : 10:54:07
|
| N/B: (A/B)z1 is supposed to be (A/B)to the power z1 and so on for the rest of the query. Couldn't do it here...Again, thats only for result1 - I'll require a more robust query to accomodate 200 cominations instead of me typing in the first combination...Thanks for all your inputs |
 |
|
|
|
|
|