0% found this document useful (0 votes)
1 views5 pages

SQL Tables

The document contains SQL queries for five different tables: students, products, employees, orders, and books. Each table includes various operations such as selecting specific columns, filtering data, counting records, and retrieving distinct values. The queries demonstrate basic SQL functionalities like ordering, averaging, and conditional selection.
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)
1 views5 pages

SQL Tables

The document contains SQL queries for five different tables: students, products, employees, orders, and books. Each table includes various operations such as selecting specific columns, filtering data, counting records, and retrieving distinct values. The queries demonstrate basic SQL functionalities like ordering, averaging, and conditional selection.
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
You are on page 1/ 5

1st Table

1. SELECT name, marks FROM students;

2. SELECT name, marks FROM students WHERE marks > 75;

3. SELECT * FROM students ORDER BY marks DESC;

4. SELECT AVG(marks) AS average_marks FROM students;


8
5. SELECT * FROM students WHERE name >= 'C';
2nd Table

1. SELECT name FROM products ORDER BY price ASC LIMIT 1;


Notebook
2. SELECT COUNT(*) FROM products WHERE category = 'Electronics';
3
3. SELECT name FROM products WHERE name LIKE 'P%';
Phone
4. SELECT price FROM products WHERE name = 'Chair';
3000
5. SELECT DISTINCT category FROM products;
3rd Table

1. SELECT name FROM employees WHERE department = 'HR';

2. SELECT salary FROM employees WHERE name = 'Bob';


55000
3. SELECT DISTINCT department FROM employees;

4. SELECT MAX(salary) AS highest_salary FROM employees;


60000
5. SELECT COUNT(*) AS total_employees FROM employees;
5
4th Table

1. SELECT customer_name FROM orders WHERE product = 'Phone';

2. SELECT COUNT(*) FROM orders WHERE status = 'Delivered';


2
3. SELECT product, quan ty FROM orders WHERE quan ty > 1;

4. SELECT DISTINCT status FROM orders;

5. SELECT customer_name FROM orders WHERE product = 'Laptop';


5th Table

1. SELECT tle FROM books WHERE genre = 'Fic on';

2. SELECT author FROM books WHERE price < 400;

3. SELECT COUNT(*) FROM books WHERE genre = 'Science';


1
4. SELECT DISTINCT genre FROM books;

5. SELECT price FROM books WHERE tle = 'Atomic Habits';


450

You might also like