-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_Select_query.sql
More file actions
72 lines (42 loc) · 1.1 KB
/
05_Select_query.sql
File metadata and controls
72 lines (42 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
USE college;
-- SELECT queries to retrieve data from the students table
-- Basic SELECT queries
SELECT * FROM students;
SELECT name, email FROM students;
SELECT student_id, name, email FROM students;
SELECT * FROM students
WHERE age > 20;
SELECT name FROM students
WHERE city = 'Hyderabad';
SELECT name from students
WHERE city = "mumbai" OR age > 22;
SELECT * FROM students
WHERE age > 20 AND city = 'Hyderabad';
SELECT name from students
WHERE age BETWEEN 20 AND 30;
SELECT name AS student_name, city AS location
FROM students;
-- Scenario Based:
SELECT name, salary FROM employees
WHERE salary > 50000;
SELECT * FROM products
WHERE category = "Electronics";
SELECT * FROM students
ORDER BY score DESC
LIMIT 5;
SELECT COUNT(*) AS total_students
FROM orders;
SELECT customer_name, email
FROM customers
WHERE city IN ("Chennai","Bangalore");
SELECT DISTINCT category
FROM products;
SELECT dept, AVG(salary) AS avg_salary
FROM employees
GROUP BY dept;
SELECT *
FROM users
WHERE last_login >= DATE_SUB(CURDATE(), INTERVAL 7 DAY);
SELECT product_name, quantity
FROM products
WHERE quantity < 10;