sql order of execution

 We all know SQL, but most of us do not understand the internals of it.


Let me take an example to explain this better. Select p.plan_name, count(plan_id) as total_count From plans p Join subscriptions s on s.plan_id=p.plan_id Where p.plan_name !=’premium’ Group by p.plan_name Having total_count > 100 Order by p.plan_name Limit 10; Step 01: Get the table data required to run the sql query Operations: FROM, JOIN (From plans p, Join subscriptions s) Step 02: Filter the data rows Operations: WHERE (where p.plan_name=’premium’) Step 03: Group the data Operations: GROUP (group by p.plan_name) Step 04: Filter the grouped data Operations: HAVING (having total_count > 100) Step 05: Select the data columns Operations: SELECT (select p.plan_name, count(p.plan_id) Step 06: Order the data Operations: ORDER BY (order by p.plan_name) Step 07: Limit the data rows Operations: LIMIT (limit 100) Knowing the Internals really help. where does distinct keyword fits in the above ordering? Do mention in comments.
#bigdata #dataengineering #sql

No comments:

Post a Comment

server laravel application

 asset_url = domain/public chmod -R 755 public/admin/ composer dump-autoload get the application from hostinger