我正在尝试运行查询,其中收到客户的姓名,发货日期,订单日期以及延迟的天数。如果延迟的天数大于10天,它应该只显示所有这些。下面是我到目前为止的代码和结果。
唯一的问题是,应该只显示一行,但它会显示数据库中的每个客户。这似乎是一个简单的修复,但我无法弄清楚。 任何帮助表示赞赏。感谢。
Execute:
select Customers.customerName as 'customer name',
shipdate.shippedDate as 'ship date',
shipdate.orderDate as 'order date',
datediff (shipdate.shippedDate, shipdate.orderDate) as 'days late'
from Customers join Orders
on Customers.customerNumber = Orders.customerNumber
join Orders as shipdate join Orders as orderday
on shipdate.shippedDate = orderday.shippedDate
where datediff (shipdate.shippedDate, shipdate.orderDate) > 10
+ ------------------ + -------------- + --------------- + -------------- +
| customer name | ship date | order date | days late |
+ ------------------ + -------------- + --------------- + -------------- +
| Online Diecast Creations Co. | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Blauer See Auto, Co. | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Vitachrome Inc. | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Baane Mini Imports | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Euro+ Shopping Channel | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Danish Wholesale Imports | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Rovelli Gifts | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Land of Toys Inc. | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
| Cruz & Sons Co. | 2003-12-26 00:00:00 | 2003-10-22 00:00:00 | 65 |
答案 0 :(得分:0)
应该尝试这样的事情:
{{1}}