カテゴリ コードと識別コードを使用して 1 つの一意の値を決定する 3 つのテーブルがあります。これをレコードと呼びましょう。同じ識別コードと異なるカテゴリ コードの値があるため、3 つのテーブルのそれぞれについて両方の値を結合する必要があります。
私は SQL に非常に慣れていないので、おそらく単純な間違いを犯していますが、3 番目のテーブルの結果は、返された行の残りの結果と一致していません。
私の最善の推測は b/c です。テーブル a には複数の結果がありますが、テーブル c には 1 つの結果しかありませんが、それはテーブル b にも当てはまり、テーブル b のデータは正確です。
サンプルコード
select a.category_code,
a.identification_code,
a.multiple_values,
b.date,
c.unique_value
from table_1 a
join table_2 b
on a.category_code = b.category_code
and a.identification_code = b.identification_code
join table_3 c
on c.category_code = a.category_code
and c.identification_code = a.identification_code
Where a.multiple_values in ('a', 'b', 'c', 'd', 'e', 'f')
and trunc(b.date) >= '01-MAY-2013'
and trunc(b.date) <= '31-MAY-2013'
サンプル結果
category_code/ identification_code/ multiple_values / date / unique_value
1520 / 557892211 / a / 05/25/2013 / Iowa
1520 / 557892211 / b / 05/25/2013 / Utah
1520 / 557892211 / c / 05/25/2013 / Arizona
1520 / 557892211 / d / 05/25/2013 / Texas
1520 / 557892211 / e / 05/25/2013 / Arkansas
1520 / 557892211 / f / 05/25/2013 / Kansas
私が抱えている問題は、実際のデータでは 1520-557892211 の一意の値がアイオワであることですが、正しい値を取得するのは 1 回だけで、残りのデータでは一意の値が正しくマッピングされていません。