SQL Concepts
SQL Concepts
3. How does the GROUP BY clause work, and when should you use it?
GROUP BY groups rows that have the same values in specified columns and allows
aggregate functions to be applied to each group.
Example: SELECT customer_id, SUM(order_amount) FROM orders GROUP BY customer_id;
Automation in SQL
1. What are SQL triggers, and how do they help automate tasks?
SQL triggers are special procedures that are automatically executed in response to
specific events on a table (e.g., INSERT, UPDATE, DELETE).
Example: CREATE TRIGGER log_update AFTER UPDATE ON employees FOR EACH ROW INSERT
INTO employee_audit (emp_id, update_time) VALUES (OLD.id, NOW());
Table Constraints
1. What are table constraints, and why are they necessary?
Constraints enforce rules on data in tables, ensuring accuracy, integrity, and
consistency.