Which SQL command is used to retrieve data from a database?
Answer: A
SELECT is the standard SQL command used to retrieve or query data from one or more tables in a database.
Q.2Easy
What does the WHERE clause do in SQL?
Answer: B
The WHERE clause is used to filter records that meet specified conditions in a SQL query.
Q.3Easy
Which keyword is used to eliminate duplicate rows in SQL results?
Answer: B
The DISTINCT keyword removes duplicate rows from the result set of a query.
Q.4Easy
What is the correct syntax for inserting data into a table?
Answer: A
INSERT INTO is the correct SQL syntax for inserting new records into a table, followed by the table name and VALUES clause.
Q.5Easy
Which SQL aggregate function returns the total sum of a numeric column?
Answer: C
The SUM() function calculates the total sum of all values in a numeric column.
Advertisement
Q.6Easy
What will be the output of: SELECT COUNT(*) FROM employees;
Answer: B
COUNT(*) returns the total number of rows in the specified table, including NULL values.
Q.7Easy
Which statement is used to modify existing data in a table?
Answer: C
The UPDATE statement is used to modify existing records in a table.
Q.8Easy
In SQL, which clause is used to filter groups based on aggregate function results?
Answer: A
HAVING clause filters groups created by GROUP BY, while WHERE filters individual rows before grouping.
Q.9Easy
Which data type in SQL is used to store large text documents or binary data?
Answer: C
BLOB (Binary Large Object) stores large binary data. CLOB stores large text. TEXT is limited compared to BLOB/CLOB.
Q.10Easy
What is the purpose of the DISTINCT keyword in SQL?
Answer: B
DISTINCT eliminates duplicate rows from query results, ensuring each unique combination appears only once.
Q.11Easy
Which SQL JOIN returns only matching rows from both tables?
Answer: C
INNER JOIN returns only rows where join condition is satisfied in both tables. Other JOINs include non-matching rows.
Q.12Easy
What will be the result of: SELECT 10 % 3; in SQL?
Answer: B
The modulus operator (%) returns remainder after division. 10 divided by 3 gives remainder 1.
Q.13Easy
What is the result of: SELECT CASE WHEN 1=1 THEN 'A' WHEN 2=2 THEN 'B' ELSE 'C' END;?
Answer: B
CASE statement evaluates conditions sequentially and returns value for first TRUE condition. 1=1 is TRUE, so 'A' is returned.
Q.14Easy
Which SQL command is used to remove all records from a table without removing the table structure?
Answer: B
TRUNCATE removes all rows but keeps the table structure. DELETE removes rows one by one and can be rolled back. DROP removes the entire table.
Q.15Easy
In a student enrollment database, you need to find students enrolled in multiple courses. Which JOIN type should be used to match course_id from enrollment table with course table?
Answer: A
INNER JOIN returns only matching records from both tables, perfect for finding students with matching course enrollments.
Q.16Easy
What is the default sort order for ORDER BY clause in SQL?
Answer: A
ORDER BY sorts in ascending order by default. Use DESC keyword for descending order.
Q.17Easy
Which aggregate function ignores NULL values in SQL?
Answer: D
COUNT(column_name), SUM(), AVG(), MAX(), and MIN() all ignore NULL values. COUNT(*) counts all rows including NULLs.
Q.18Easy
Which SQL statement is used to add a new column to existing table?
Answer: B
ALTER TABLE ... ADD COLUMN syntax is correct for adding columns. Other options are invalid SQL syntax.
Q.19Easy
Which feature of SQL allows preventing duplicate values in a column?
Answer: B
UNIQUE constraint prevents duplicate values. PRIMARY KEY is unique + NOT NULL. NOT NULL only prevents nulls. FOREIGN KEY maintains referential integrity.