现在遇到这样一个需求
我的索引里面保存了从各个网站爬回来对产品以及价格信息,基本信息是这样
product_id, source_id,price,discount
所以我通过 collapse 对 product_id 进行折叠分组,并且是通过 price 来排序的,所以得到对结果就是每个 product 的最低价,但是我现在还想对这个返回对结果再次排序,比如通过 discount 来排序,应该怎么做呢?
mysql 大概是这样
select * from (select * from product group by product_id order by price asc ) t order by discount desc
用 aggregation 目前没有思路
我的索引里面保存了从各个网站爬回来对产品以及价格信息,基本信息是这样
product_id, source_id,price,discount
所以我通过 collapse 对 product_id 进行折叠分组,并且是通过 price 来排序的,所以得到对结果就是每个 product 的最低价,但是我现在还想对这个返回对结果再次排序,比如通过 discount 来排序,应该怎么做呢?
mysql 大概是这样
select * from (select * from product group by product_id order by price asc ) t order by discount desc
用 aggregation 目前没有思路
