0

Assume my query will join multiple tables. (Thanks for suggestion about ANSI JOIN and conventional JOIN, but that is not my point here).

SELECT 
     *
FROM 
     TableA, 
     TableB, 
     (SELECT * FROM TableC WHERE TableC.department != 'R&D') as TableC
WHERE
     TableA.user = TableB.user
     AND TableA.user = TableC.user

I want to quickly get any 10 rows (top, or random) to preview if the table is what I want. Other than

SELECT
    *
FROM
    (SELECT 
         *
    FROM 
         TableA, 
         TableB, 
         (SELECT * FROM TableC WHERE TableC.department != 'R&D') as TableC
    WHERE
         TableA.user = TableB.user
         AND TableA.user = TableC.user)
WHERE ROWNUM <=10

what will be the most effective and efficient way to quickly get the preview rows, that not necessary wait for the subquery to finish.

ju.
  • 878
  • 1
  • 11
  • 30
  • 1
    Oracle applies rownum to the result after it has been returned. First Options will not work. – Khalil Sep 30 '17 at 07:40
  • [Possible duplicate](https://stackoverflow.com/questions/2498035/oracle-select-top-10-records) – Khalil Sep 30 '17 at 07:41
  • 1
    [Use ANSI joins instead of old joins](https://stackoverflow.com/questions/18891148/oracle-joins-comparison-between-conventional-syntax-vs-ansi-syntax) – Khalil Sep 30 '17 at 07:44
  • 1
    Possible duplicate of [Oracle SQL - How to Retrieve highest 5 values of a column](https://stackoverflow.com/questions/2306744/oracle-sql-how-to-retrieve-highest-5-values-of-a-column) – Paul Maxwell Oct 16 '17 at 06:38
  • it's `SELECT * FROM ( ... ) WHERE ROWNUM <=10` or perhaps look here for options: https://stackoverflow.com/questions/7480243/sql-oracle-order-by-and-limit – Paul Maxwell Oct 16 '17 at 06:41

0 Answers0