select order_num,total from
(select order_num, sum(item_price*quantity) as total from OrderItems
group by order_num) t
where total >=1000
order by order_num
其中的子查询语句是用来当做表的;
`select order_num from OrderItems
group by order_num
having sum(quantity)>=100
order by order_num
having 与group by 连用,可包含聚合函数;
`
将子查询作为一个where条件
union--连接表,对行操作。
union--将两个表做行拼接,同时自动删除重复的行。
union all---将两个表做行拼接,保留重复的行