Write an SQL query to retrieve all employee names in alphabetical order.
id | name | salary |
---|---|---|
1 | Amit | 40000 |
2 | Ravi | 55000 |
3 | Suman | 60000 |
4 | Neha | 45000 |
5 | Mohit | 70000 |
Write an SQL query to find employees earning more than 50,000.
Write a query to count how many customers are in each city.
id | name | city |
---|---|---|
1 | Raj | Varanasi |
2 | Sita | Delhi |
3 | Akash | Varanasi |
4 | Nitin | Mumbai |
5 | Meena | Delhi |
6 | Rohit | Varanasi |
Write a query to find the second-highest salary without using LIMIT or OFFSET.
Write a query to find customers who have placed more than 3 orders.
Customers | |
---|---|
id | name |
1 | Raj |
2 | Sita |
3 | Akash |
4 | Nitin |
Orders | |
---|---|
order_id | customer_id |
101 | 1 |
102 | 2 |
103 | 3 |
104 | 1 |
105 | 1 |
106 | 2 |
107 | 1 |
108 | 3 |
109 | 2 |
110 | 3 |