SQL SELECT-interview
Q1. What is the SELECT statement in SQL?
The SELECT statement is used to retrieve data from one or more tables in a database.
SELECT student_name, student_age FROM Students;
Q2. How do you select all columns from a table?
Use the * symbol to select all columns.
SELECT * FROM Students;
Q3. How do you filter data in SELECT?
Use the WHERE clause to filter rows based on a condition.
SELECT student_name FROM Students WHERE student_age > 18;
Q4. How do you sort results in SQL?
Use the ORDER BY clause to sort results in ascending (ASC) or descending (DESC) order.
SELECT student_name, student_age FROM Students ORDER BY student_age DESC;
Q5. How do you remove duplicate rows in SELECT?
Use the DISTINCT keyword to return only unique values.
SELECT DISTINCT course_name FROM Courses;