SQL Queries
SQL Queries
4. Aggregate Queries
Aggregate functions perform calculations on a set of rows.
Count Rows:
5. Joins
Joins combine data from multiple tables.
Inner Join
Retrieve Matching Rows from Both Tables:
sql
Copy code
SELECT * FROM table1
INNER JOIN table2 ON table1.column_name =
table2.column_name;
Left Join
Retrieve All Rows from the Left Table:
6. Constraints
Constraints enforce rules on data.
Add a Primary Key:
7. Views
Views are virtual tables based on the result of a query.
Create a View:
8. Stored Procedures
Stored procedures are reusable SQL code blocks.
Create a Stored Procedure:
EXEC procedure_name;
9. Triggers
Triggers automatically perform actions when certain events
occur.
Create a Trigger:
10. Transactions
Transactions are used to group multiple queries into a single
logical unit.
Begin Transaction:
BEGIN TRANSACTION;
Commit Changes:
COMMIT;
Rollback Changes:
ROLLBACK;