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 |
|
satish.gorijala
Posting Yak Master
182 Posts |
Posted - 2009-06-18 : 07:47:01
|
| Table1Name Stat CULTXYZ 90 INDIABC 50 ENGLXYZ 10 IRISTable2SCode INDI ENGL IRIS315 100 700 200456 346 234 40My Input is Cname = 'XYZ' and SCode = '315'. Here the Stat value of XYZ should multiply with corresponding columnin table2 with respect to CULT column in Table1XYZ (INDI)=90 (from stats) times 100 (from country of origin)=9000XYZ (ENGL)=10 (from stats) times 200 (from country of origin)=2000Need to come output value asINDI9000G. Satish |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-18 : 08:44:58
|
| Read about NormalizationTrySELECT Name,Stat*case when t1.CULT='INDI' then INDI when t1.CULT='ENGL' then ENGL when t1.CULT='IRIS' then IRIS end from table1 as t1 inner join table2 as t2 on 1=1where t1.Name='XYZ' and t2.Scode=315MadhivananFailing to plan is Planning to fail |
 |
|
|
satish.gorijala
Posting Yak Master
182 Posts |
Posted - 2009-06-18 : 09:09:12
|
Thank you. This works perfect.quote: Originally posted by madhivanan Read about NormalizationTrySELECT Name,Stat*case when t1.CULT='INDI' then INDI when t1.CULT='ENGL' then ENGL when t1.CULT='IRIS' then IRIS end from table1 as t1 inner join table2 as t2 on 1=1where t1.Name='XYZ' and t2.Scode=315MadhivananFailing to plan is Planning to fail
G. Satish |
 |
|
|
|
|
|