注文が行われた最大(日付)を見つけようとしている場所が 1900 あります。また、その関連する場所/日付の注文コストと注文数量。
このデータを取得するためにサブクエリまたは結合を作成するにはどうすればよいですか。
以下の試行例:
select table1.location, table2.ord_dt, table2.order_cost, table2.order_qty
from table2
join table 3 on table2.id1 = table3.id1
join table 1 on table1.id1 = table3.id2
where table2.ord_dt = (
select table1.location, max(table2.ord_dt)
from table2
join table 3 on table2.id1 = table3.id1
join table 1 on table1.id1 = table3.id2
group by table1.location
ロジックがオフになっていると確信しており、「述語演算子の両側の要素数が一致しません」というエラーが表示されます。おそらく、サブクエリをプルするよりもメインクエリに多くの列が必要だからです。
任意のガイダンスをいただければ幸いです。