场景:

查询出 图书和食品两个分类(或多个分类) 在最新的一天内的商品销售情况 


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  order by prod_class