0
点赞
收藏
分享

微信扫一扫

bash引用-Quoting详细介绍

题目

产品数据表: Products

写一段 SQL来查找在 2019-08-16 时全部产品的价格,假设所有产品在修改前的价格都是 10 。

以 任意顺序 返回结果表。

查询结果格式如下例所示。

示例 1:

 

 

解题思路

代码实现

(select product_id , 10 as price
from Products
group by product_id
having min(change_date)>'2019-08-16')
union
(select product_id, new_price as price
from Products
where(product_id, change_date) in
                                (select product_id, max(change_date) as change_date
                                from Products
                                where change_date <= '2019-08-16'
                                group by product_id))

 

测试结果

举报

相关推荐

0 条评论