0
(第2表の列値への最初のテーブルからの行の値)に基づいて、別のSQL - でつのテーブルを結合以下のように見える私は2つのテーブルを有する
最初の表:
DealNum CurrencyValue CurrencyCode Date
110 100 AA 01/12/2011
111 200 AB 01/11/2011
112 120 AC 01/10/2011
113 20 AA 01/11/2011
110 103 AD 01/12/2011
115 200 AD 01/11/2011
119 120 AG 01/10/2011
130 20 AK 01/11/2011
二番目の表
CurrencyCode OCT NOV DEC JAN ..
AA 0.91 0.88 0.9 0.94
AB 0.9 0.8 0.96 0.89
AC 0.81 0.79 0.82 0.84
AD 0.4 0.41 0.42 0.39
AE 0.9 0.92 0.91 0.94
AF 0.8 0.82 0.83 0.81
は、今私は、以下の条件で新しい列の最初の表に2つ目のテーブルからデータを追加したい
1.It has to do based on the CurrencyCode and month
2.If the deal is from DEC and currencyCode is AA , then it has to take the value 0.9,
if the deal is from NOV and currencyCode is AA , then it has to take the value 0.88..
だから、結果は、私は2番目のテーブルにある月の列の値に最初のテーブルから月の行値を比較してこれを行う方法について見当もつかないこの
DealNum CurrencyValue CurrencyCode Date NewColumn
110 100 AA 01/12/2011 0.9
111 200 AB 01/11/2011 0.8
112 120 AC 01/10/2011 0.81
113 20 AA 01/11/2011 0.88
110 103 AD 01/12/2011 0.42
115 200 AD 01/11/2011 0.41
119 120 AG 01/10/2011 --
130 20 AK 01/11/2011 --
のようになります。これで助けてください。
ありがとうございます。
乾杯、 Harish。
おかげでティムSchmelter ...この1つは私のために正常に動作...素晴らしいです。しかし、ここのことは、2番目のテーブルの列名(月)が毎回変わるのを防ぎます。t1.date = t2。(XYZ月)、t2.Janまたはt2のように動的な方法があります。 2月?あなたの助けをもう一度ありがとう:)) – harry