+ 1

What happens with two filters in SQL

What happens in SQL when aggregation functions like AVG() , WHERE, GROUP BY, HAVING, LIKE are used simultaneously in a statement. If valid, what is the order followed.

19th Oct 2023, 8:22 AM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar
3 Answers
+ 5
SQL execute as the order below. FROM/JOIN WHERE GROUP BY HAVING SELECT ORDER BY LIMIT/OFFSET AVG() is belong to the SELECT clause. It is totally valid to put those keywords in a single SQL statement.
19th Oct 2023, 9:17 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Shashank Reddy Voorelli In which clause your write %LIKE%? Answer: WHERE clause. So %LIKE% belongs to WHERE clause. The SQL will do what you ask for given you write it correctly. [EDIT] %LIKE% also works with HAVING too!
19th Oct 2023, 9:26 AM
Wong Hei Ming
Wong Hei Ming - avatar
0
Wong Hei Ming could you please tell me what happens with 'LIKE' also. Thank you.
19th Oct 2023, 9:22 AM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar