- select[distinct]
- from
- join(如left join)
- on
- where
- group by
- having
- union
- order by
- limit
-
- select distinct sum(a.OrderPrice) As order1,sum(d.OrderPrice) As order2
- from orders a
- left join (select c.* from Orders c) d
- on a.O_Id = d.O_Id
- where a.Customer='Bush' or a.Customer = 'Adams' or a.Customer = 'Carter'
- group by a.Customer
- having sum(a.OrderPrice) > 1500
- union
- select distinct sum(a.OrderPrice) As order1,sum(e.OrderPrice) As order2
- from orders a
- left join (select c.* from Orders c) e
- on a.O_Id = e.O_Id
- where a.Customer='Bush' or a.Customer = 'Adams' or a.Customer = 'Carter'
- group by a.Customer
- having sum(a.OrderPrice) > 2000
- order by order1
- limit 1
mysql 语句执行顺序
最新推荐文章于 2022-12-29 14:15:28 发布