我希望在不使用任何GROUP BY和ROWNUM功能的情況下獲得每種產品的最低銷售額。只是想知道我怎麼能做到這一點。任何投入將不勝感激。如何在不使用GROUP BY和ROWNUM的情況下獲得產品的最低銷售額
-3
A
回答
1
如果我正確理解你的問題,你想是這樣的:
SELECT DISTINCT ON (product_id) product_id, sales
FROM mytable
ORDER BY product_id, sales;
1
試試這個,
SELECT value,productid FROM
table T1
WHERE value=(select min(value)
from table t2
where t1.productid=t2.productid)
0
不知道表結構,這是不可能正確地回答。不過,假設你orders
表有一個order_id
(PK),一個customer_id
和sales
列,這應該這樣做:
select o1.product_id, o1.sales
from orders o1
where o1.sales <= all (select o2.sales
from orders o2
where o2.product_id = o1.product_id
and o2.order_id <> o1.order_id);
相關問題
- 1. 獲得銷售額最高的產品
- 2. 如何比較銷售數組並獲得最高和最低的銷售額
- 3. 從銷售周開始獲得最低銷售額
- 4. 最少銷售的產品
- 5. 如何在產品列表視圖中獲得產品最小銷售數量?
- 6. 如何在不使用GROUP BY的情況下進行聚合?
- 7. 返回每天或產品的總銷售額和平均銷售額
- 8. 如何定製Sylius以銷售免費產品(默認情況下,最低價格爲0.01)
- 9. 用HAVING和GROUP BY獲得總金額
- 10. 兩個產品的總和月銷售額,mysql查詢
- 11. 獲得總銷售額
- 12. SQL的最高銷售的產品
- 13. 的Rails獲得最暢銷的產品
- 14. 如何獲得/計算銷售總額及其銷售
- 15. 如何在銷售訂單的每一行都關閉的情況下獲得銷售訂單?
- 16. Magento - 獲得暢銷產品包括售罄產品
- 17. 試圖獲得每個銷售渠道的TOP 10產品
- 18. 獲取magento 1.9.x的銷售產品
- 19. 如何在沒有龐大子查詢的情況下在SELECT中獲得總銷售額的百分比
- 20. WooCommerce:獲取SQL查詢中產品變體的總銷售額
- 21. Oracle SQL查詢:獲得員工的最大銷售額
- 22. XSLT - 在這種情況下如何使用group by?
- 23. 在這種情況下,我如何使用MySQL Group By?
- 24. 跟蹤一週/月的銷售情況並找到暢銷產品
- 25. 按月產品銷售 - SQL
- 26. MySQL的GROUP BY產品
- 27. 顯示產品名稱和城市,該產品的銷售量最大
- 28. 如何獲得每月銷售額的總和?
- 29. MySQL使用JOIN/GROUP BY時的情況
- 30. 如何使用具有GROUP BY的SELECT和具有在特定SQL情況下
您可以使用窗口函數? –
不使用任何功能。 – Teja
@SOaddict爲什麼不呢? – redneb