从订单行计算订单总和
您好,我正在尝试计算订单的总和。 我收到了一个带有 ID 的订单,以及一些订单行。
Order
ID OrderDate CustomerName
OrderLine
OrderID ProductId Amount Price
我想做一个选择语句,我得到以下输出。
ID、订单日期、客户名称、订单总计。
Hi I'm trying to calc the sum of an order.
I got an order with and Id, and a number of Orderlines.
Order
ID OrderDate CustomerName
OrderLine
OrderID ProductId Amount Price
I would like to make a select statement, where I get the following output.
ID, OrderDate, CustomerName, OrderTotal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要
JOIN
、GROUP BY
和SUM
。像这样的东西:You need a
JOIN
,GROUP BY
andSUM
. Something Like:你的问题不完整。但我会尝试猜测剩下的缺失部分。
假设您有两张表。一个表包含 Orders ,我们将其称为
tbl_orders
,另一个表包含订单详细信息,并将其称为tbl_details
。我就是这样做的
Your question is incomplete. But I will try to guess the remaining missing parts.
Let's assume that you have two tables. One table has Orders , we will call it
tbl_orders
and another that has the details of the orders and will call ittbl_details
.here is how I would do it