0% found this document useful (0 votes)
12 views1 page

Essential SQL Query Examples

Practical SQL Examples

Uploaded by

nedaakhaledjaber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Essential SQL Query Examples

Practical SQL Examples

Uploaded by

nedaakhaledjaber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical SQL Examples

SELECT Queries
Example: SELECT name, age FROM Employees WHERE age > 30; retrieves employees older
than 30.

Joins
Example: SELECT [Link], d.department_name FROM Employees e JOIN Departments d ON
e.dept_id = [Link]; combines data from two tables.

Subqueries
Example: SELECT name FROM Employees WHERE salary > (SELECT AVG(salary) FROM
Employees); finds employees earning above average.

Aggregations
Example: SELECT department_id, COUNT(*) FROM Employees GROUP BY department_id;
counts employees per department.

Sorting & Filtering


Example: SELECT * FROM Products WHERE price BETWEEN 50 AND 200 ORDER BY price
DESC; filters and sorts product data.

You might also like