QuXiangjie / Study-Review

自己欠缺的还太多了,希望通过总结每天的学习内容,整理每天的思绪来丰富自己的知识库。我想成为一名优秀的金融数据分析师,并行发展技术与商业业务。博客内容为:数理统计、财务业务、Python(数据分析及可视化)、Excel(数据分析)、SQL、英文
0 stars 0 forks source link

1164. Product Price at a Given Date #28

Open QuXiangjie opened 4 months ago

QuXiangjie commented 4 months ago

https://leetcode.com/problems/product-price-at-a-given-date/

select distinct product_id, 10 as price from Products where product_id not in(select distinct product_id from Products where 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 date from Products where change_date <='2019-08-16' group by product_id)