SQL 中的附加查询无法正常工作
插入表2(客户、订单日期、印章日期、行程距离、单位、国家/地区、评论)
选择
'CustomerFamily' As Customer,
T1.Order_Date AS Order_Date,
T1.Stamp_Date AS Stamp_Date,
T1.Travelled_Distance-T2.Travelled_Distance AS Travelled_Distance,
T1.Units AS Units,
'Canada' AS Country,
'' AS Comments
来自
Table1 AS T1,
Table1 AS T2
地点
T1.Customer='Jake' And
T2.Customer='Mike' And
T2.Order_Date=T1.Order_Date
< strong>ORDER BY
T1.Order_Date;
这是我的附加查询,其中有一个计算(对于杰克和迈克在同一天旅行的日子,它减去了杰克的迈克旅行距离
) 问题是它很好地完成了所有计算并将其放入表 2 中,但有两行对于每个计算都是相同的。
为什么重复两次?我无法发现错误
INSERT INTO Table2 ( Customer, Order_Date, Stamp_Date, Travelled_Distance, Units, Country, Comments )
SELECT
'CustomerFamily' As Customer,
T1.Order_Date AS Order_Date,
T1.Stamp_Date AS Stamp_Date,
T1.Travelled_Distance-T2.Travelled_Distance AS Travelled_Distance,
T1.Units AS Units,
'Canada' AS Country,
'' AS Comments
FROM
Table1 AS T1,
Table1 AS T2
WHERE
T1.Customer='Jake' And
T2.Customer='Mike' And
T2.Order_Date=T1.Order_Date
ORDER BY
T1.Order_Date;
This is my append query that has a calculation in it ( for the days that jake and mike travel on same day it subtracts mikes travel distance from jakes)
the PROBLEM is that it does all the calculation fine and puts it into Table 2 but there is two rows which are the same for every single calculation.
why is it repeating twice? I can't spot the error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
Try