Questions tagged «top-n»


5
Oracle SELECT TOP 10记录
我在Oracle中使用SQL语句遇到了很大的问题。我想选择STORAGE_DB排序的前10条记录,这些记录不在其他select语句的列表中。 此记录适用于所有记录: SELECT DISTINCT APP_ID, NAME, STORAGE_GB, HISTORY_CREATED, TO_CHAR(HISTORY_DATE, 'DD.MM.YYYY') AS HISTORY_DATE FROM HISTORY WHERE STORAGE_GB IS NOT NULL AND APP_ID NOT IN (SELECT APP_ID FROM HISTORY WHERE TO_CHAR(HISTORY_DATE, 'DD.MM.YYYY') = '06.02.2009') 但是当我添加 AND ROWNUM <= 10 ORDER BY STORAGE_GB DESC 我正在获取某种“随机”记录。我认为是因为限价是在下订单之前进行的。 有人有好的解决方案吗?另一个问题:此查询的速度非常慢(超过10k条记录)
144 sql  oracle  top-n 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.