Friday, 7 December 2018

Order of Query Execution in Oracle

FROM & JOINs determine & filter rows
WHERE more filters on the rows
GROUP BY combines those rows into groups
HAVING filters groups
ORDER BY arranges the remaining rows/groups
LIMIT filters on the remaining rows/groups

1 comment:

  1. Having Clause may come prior/before the group by clause.

    Example: select * FROM test_std;

    ROLL_NO SNAME DOB TEACH
    1 John 27-AUG-18 Wills
    2 Knit 27-AUG-18 Prestion
    3 Perl 27-AUG-18 Wills
    4 Ohrm 27-AUG-18 Woods
    5 Smith 27-AUG-18 Charmy
    6 Jony 27-AUG-18 Wills
    Warner 20-NOV-18 Wills
    Marsh 12-NOV-18 Langer
    FINCH 18-OCT-18 Langer


    9 rows selected.

    select teach, count() count from test_std having count() > 1 group by TEACH ;

    TEACH COUNT
    ---------- ----------
    Langer 2
    Wills 4

    ReplyDelete