0% found this document useful (0 votes)
45 views6 pages

Essential SQL Queries for Data Analysis

This document contains 17 SQL queries that perform various operations on database tables like employees, customers, and payments. The queries select, filter, aggregate, and manipulate data using functions like SELECT, COUNT, MAX, MIN, AVG, SUM, ROUND, CONCAT, SUBSTRING, UPPER, CHAR_LENGTH, and LIKE.

Uploaded by

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

Essential SQL Queries for Data Analysis

This document contains 17 SQL queries that perform various operations on database tables like employees, customers, and payments. The queries select, filter, aggregate, and manipulate data using functions like SELECT, COUNT, MAX, MIN, AVG, SUM, ROUND, CONCAT, SUBSTRING, UPPER, CHAR_LENGTH, and LIKE.

Uploaded by

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

SQL QUERY

1. SELECT * FROM employees ORDER BY firstName DESC

2. SELECT contactFirstName'First Name', contactLastName'Last Name' FROM


customers

3. SELECT MAX(amount) 'Maximum', MIN(amount) 'Minimum' FROM payments


SQL QUERY

4. SELECT AVG(amount), COUNT(DISTINCT customerNumber) FROM payments

5. SELECT COUNT(DISTINCT jobTitle) FROM employees

6. SELECT UPPER(firstName) FROM employees


SQL QUERY

7. SELECT SUBSTRING(firstName, 1, 3) FROM employees

8. SELECT DISTINCT employeeNumber FROM employees

9. SELECT SUM(amount) FROM payments


SQL QUERY

10. SELECT ROUND(MAX(amount)), ROUND(MIN(amount)), ROUND(SUM(amount)),


ROUND(AVG(amount)) FROM payments

11. SELECT (COUNT(jobTitle) - COUNT(DISTINCT jobTitle) + 1) 'Same Job' FROM


employees

12. SELECT (MAX(amount) - MIN(amount)) 'Difference' FROM payments


SQL QUERY

13. SELECT CONCAT(contactFirstName, ' ',contactLastName), creditLimit FROM


customers WHERE creditLimit> (SELECT creditLimit FROM customers WHERE
contactFirstName = 'Eric')

14. SELECT CONCAT(contactFirstName, ' ',contactLastName) FROM customers

15. SELECT firstName FROM employees WHERE firstName LIKE '%a%' AND firstName
LIKE '%e%'
SQL QUERY

16. SELECT lastName FROM employees WHERE CHAR_LENGTH(lastName) = 6

17. SELECT lastName FROM employees WHERE lastName LIKE '__e%'

You might also like