1. 根据占用库存排序热销商品
select goods.id,
nvl(goods.name, ''),
nvl(goods.price, 0),
TO_CHAR(SUBSTR(goods.goodsimageliststore,
(INSTR(goods.goodsimageliststore,
'sourceGoodsImagePath',
1,
1) + 23),
(INSTR(goods.goodsimageliststore,
'thumbnailGoodsImagePath',
1,
1) - INSTR(goods.goodsimageliststore,
'sourceGoodsImagePath',
1,
1) - 26))) imageUrl,
temp.freezeStore
from (select tg.id, sum(nvl(tp.freezeStore, 0)) as freezeStore
from tsp_goods tg
left join tsp_product tp
on tp.goods_id = tg.id
where tg.isdelete = 0
and tg.isMarketable = 1
and tg.store_id = 'f9895ca72f8c31fc012f94e06f5e0249'
group by tg.id
order by freezeStore desc) temp
join tsp_goods goods
on temp.id = goods.id