diff --git a/controllers/reports.js b/controllers/reports.js index 5ec95f2..6158fe8 100644 --- a/controllers/reports.js +++ b/controllers/reports.js @@ -33,11 +33,11 @@ async function getHotProducts(ctx) { const limit = parseInt(ctx.query.limit) || 10 const rows = await query( - `SELECT id, name, price, sales, stock, + `SELECT goods.id, goods.name, goods.price, goods.sales, goods.stock, COALESCE(s.quantity, 0) as stock_qty FROM goods LEFT JOIN stock s ON goods.id = s.goods_id - ORDER BY sales DESC + ORDER BY goods.sales DESC LIMIT ?`, [limit] )