表设计:
需求:
1.先找出各个分类中销售的最新日期
select prod_class,max(sales_date) as sn from prod_sales group by prod_class
2.根据日期和分类去匹配数据
select a.* from prod_sales a inner join ( select prod_class, max(sales_date) as sn from prod_sales group by prod_class) b on a.prod_class = b.prod_class and a.sales_date = b.sn;