【发布时间】:2013-12-14 19:41:03
【问题描述】:
在使用 Teradata 时需要一些帮助我需要提取一个连接多个表的报表...这是基本概念:
Select Table1.ID, Table2.Arrival_date, Table2.Name
From Table1
Inner Join Table1.ID on Table2.ID
Where table2.arrival_date between '10/01/2013' and '10/02/2013'
然后是另一个表,其中包含以下信息
ID Item Cost Date
1 Flour 1.99 10/02/2013
2 cheese 3.99 10/01/2013
3 Flour 1.99 8/16/2013
我想把这个添加到上面的表格中
Select Itemtable.ID, Itemtable.item, itemtable.cost, itemtable.date
from itemtable
where itemtable.date between '10/01/2013' and 10/02/2013
and itemtable.item like '%flour%'
Itemtable.ID = Table1.ID - 但是当我加入时,我只会得到那些购买面粉的客户 - 我希望在该日期范围内看到所有客户,如果他们购买面粉想要它 - 我的决赛桌会看起来像这样:
ID Arrival Date Name ID Item Cost Date
1 10/01/2013 Dan
2 10/01/2013 Mike
3 10/01/2013 Nancy
1 10/02/2013 Dan 1 Flour 1.99 10/02/2013
5 10/02/2013 Mary
任何帮助将不胜感激!
【问题讨论】:
-
请告诉我们您的表格名称及其关联。提前致谢!
标签: sql join teradata database-table