Join our telegram channel to learn how data analysis can reveal fascinating patterns, trends, and stories hidden within the numbers! ๐
For ads & suggestions: @love_data
Post #2232
1.49K
โ
Basic SQL Queries Interview Questions With Answers ๐ฅ๏ธ
1. What does SELECT do
โ SELECT fetches data from a table
โ You choose columns you want to see
Example: SELECT name, salary FROM employees;
2. What does FROM do
โ FROM tells SQL where data lives
โ It specifies the table name
Example: SELECT * FROM customers;
3. What is WHERE clause
โ WHERE filters rows
โ It runs before aggregation
Example: SELECT * FROM orders WHERE status = 'Delivered';
4. Difference between WHERE and HAVING
โ WHERE filters rows before GROUP BY
โ HAVING filters groups after aggregation
Example: WHERE filters orders, HAVING filters total_sales
5. How do you sort data
โ Use ORDER BY
โ Default order is ASC
Example: SELECT * FROM employees ORDER BY salary DESC;
6. How do you sort by multiple columns
โ SQL sorts left to right
Example: SELECT * FROM students ORDER BY class ASC, marks DESC;
7. What is LIMIT
โ LIMIT restricts number of rows returned
โ Useful for top N queries
Example: SELECT * FROM products LIMIT 5;
8. What is OFFSET
โ OFFSET skips rows
โ Used with LIMIT for pagination
Example: SELECT * FROM products LIMIT 5 OFFSET 10;
9. How do you filter on multiple conditions
โ Use AND, OR
Example: SELECT * FROM users WHERE city = 'Delhi' AND age > 25;
10. Difference between AND and OR
โ AND needs all conditions true
โ OR needs one condition true
Quick interview advice
โข Always say execution order: FROM โ WHERE โ SELECT โ ORDER BY โ LIMIT
โข Write clean examples
โข Speak logic first, syntax nextยน
Double Tap โค๏ธ For More
1. What does SELECT do
โ SELECT fetches data from a table
โ You choose columns you want to see
Example: SELECT name, salary FROM employees;
2. What does FROM do
โ FROM tells SQL where data lives
โ It specifies the table name
Example: SELECT * FROM customers;
3. What is WHERE clause
โ WHERE filters rows
โ It runs before aggregation
Example: SELECT * FROM orders WHERE status = 'Delivered';
4. Difference between WHERE and HAVING
โ WHERE filters rows before GROUP BY
โ HAVING filters groups after aggregation
Example: WHERE filters orders, HAVING filters total_sales
5. How do you sort data
โ Use ORDER BY
โ Default order is ASC
Example: SELECT * FROM employees ORDER BY salary DESC;
6. How do you sort by multiple columns
โ SQL sorts left to right
Example: SELECT * FROM students ORDER BY class ASC, marks DESC;
7. What is LIMIT
โ LIMIT restricts number of rows returned
โ Useful for top N queries
Example: SELECT * FROM products LIMIT 5;
8. What is OFFSET
โ OFFSET skips rows
โ Used with LIMIT for pagination
Example: SELECT * FROM products LIMIT 5 OFFSET 10;
9. How do you filter on multiple conditions
โ Use AND, OR
Example: SELECT * FROM users WHERE city = 'Delhi' AND age > 25;
10. Difference between AND and OR
โ AND needs all conditions true
โ OR needs one condition true
Quick interview advice
โข Always say execution order: FROM โ WHERE โ SELECT โ ORDER BY โ LIMIT
โข Write clean examples
โข Speak logic first, syntax nextยน
Double Tap โค๏ธ For More
- โค 6






