mysql求sql语句 查询订单明细金额累加与订单总金额不等的订单

mysql求sql语句 查询订单明细金额累加与订单总金额不等的订单,第1张

SELECT

o1.order_id,

MAX(o1.subtotal) AS 订单总金额,

SUM(o2.cost) AS 订单明细合计

FROM

`order` o1 JOIN order_details o2 ON (o1.order_id = o2.order_id)

GROUP BY

o1.order_id

HAVING

MAX(o1.subtotal) <>SUM(o2.cost)

SELECT

sum(price),

sum(total * cost),

DATE_FORMAT(

FROM_UNIXTIME(time, '%Y-%m-%d') AS DATA

FROM

table_order t1,

table_orderlist t2

WHERE

t1.id = t2.order_id

GROUP BY

DATE_FORMAT(

FROM_UNIXTIME(time, '%Y-%m-%d')


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5908429.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-07
下一篇 2023-03-07

发表评论

登录后才能评论

评论列表(0条)

保存