Which SQL function is used to retrieve the length of a string?
Correct answer:
A) LENGTH()
Explanation: The LENGTH() function returns the number of characters in a string.
Which SQL function is used to retrieve the length of a string?
Correct answer:
A) LENGTH()
Explanation: The LENGTH() function returns the number of characters in a string.
How do you write a SQL statement to update the value of the "Name" column to 'John' where the "ID" is 100?
Correct answer:
B) UPDATE Employees SET Name = 'John' WHERE ID = 100
Explanation: The UPDATE statement is used to modify existing data in a table.
Which SQL statement is used to remove an existing column from a table?
Correct answer:
C) ALTER TABLE DROP COLUMN
Explanation: The ALTER TABLE DROP COLUMN statement is used to delete a column from a table.
What SQL operator is used to select rows that match a specified pattern?
Correct answer:
B) LIKE
Explanation: The LIKE operator is used to search for a specified pattern in a column.
Which SQL keyword is used to select records based on a range of values?
Correct answer:
A) BETWEEN
Explanation: The BETWEEN operator is used to filter the result set within a specified range.
What does the SQL keyword IS NULL do?
Correct answer:
C) It checks if a value is NULL
Explanation: The IS NULL operator is used to check if a column contains a NULL value.
Which SQL function returns the first non-NULL value from a set of arguments?
Correct answer:
B) COALESCE()
Explanation: The COALESCE() function returns the first non-NULL value from the arguments passed to it.
Which SQL statement is used to delete all data from a table but not the table itself?
Correct answer:
C) TRUNCATE TABLE
Explanation: The TRUNCATE TABLE statement deletes all rows from a table but retains the table structure.
How do you limit the number of rows returned by a query to 10 in MySQL?
Correct answer:
B) SELECT * FROM table LIMIT 10
Explanation: The LIMIT clause is used to specify the number of rows returned in a query.
Which SQL clause is used to filter the result set after grouping?
Correct answer:
C) HAVING
Explanation: The HAVING clause is used to filter groups created by the GROUP BY clause.
What does the SQL statement ALTER TABLE do?
Correct answer:
A) It changes the structure of an existing table
Explanation: The ALTER TABLE statement is used to modify the structure of an existing table.
Which SQL function is used to find the minimum value in a column?
Correct answer:
B) MIN()
Explanation: The MIN() function returns the smallest value from the selected column.
Which SQL function is used to return the current time?
Correct answer:
A) CURRENT_TIME()
Explanation: The CURRENT_TIME() function returns the current time.
What does the SQL statement DROP INDEX do?
Correct answer:
B) It removes an index from a table
Explanation: The DROP INDEX statement deletes an index from a table.
Which SQL function is used to round a numeric value to the nearest whole number?
Correct answer:
A) ROUND()
Explanation: The ROUND() function is used to round a numeric value to the nearest whole number.
How do you select all rows where the value of the "Salary" column is greater than 5000?
Correct answer:
B) SELECT * FROM Employees WHERE Salary > 5000
Explanation: The correct SQL query uses WHERE Salary > 5000 to filter rows where the salary is greater than 5000.
What SQL clause is used to filter rows based on a specific condition?
Correct answer:
B) WHERE
Explanation: The WHERE clause is used to filter records based on specified conditions.
Which SQL clause is used to order the result set in ascending or descending order?
Correct answer:
B) ORDER BY
Explanation: The ORDER BY clause is used to sort the result set in ascending or descending order.
Which SQL function is used to return the largest value in a column?
Correct answer:
A) MAX()
Explanation: The MAX() function returns the largest value in the selected column.
How do you remove duplicates from the result set in a SELECT query?
Correct answer:
A) SELECT DISTINCT
Explanation: The DISTINCT keyword is used to return only unique values from the result set.
Which SQL clause is used to group rows that have the same values?
Correct answer:
A) GROUP BY
Explanation: The GROUP BY clause is used to group rows that have the same values in specified columns.
How do you retrieve the total number of rows in a table?
Correct answer:
A) SELECT COUNT(*) FROM table
Explanation: The COUNT(*) function returns the total number of rows in a table.
Which SQL operator is used to test for inequality?
Correct answer:
D) BOTH A AND C
Explanation: Both != and <> are used to test for inequality in SQL queries.
What SQL function is used to remove leading and trailing spaces from a string?
Correct answer:
B) TRIM()
Explanation: The TRIM() function removes leading and trailing spaces from a string.
Which SQL keyword is used to limit the number of rows returned by a query in SQL Server?
Correct answer:
B) TOP
Explanation: The TOP keyword is used in SQL Server to limit the number of rows returned.
What is the purpose of the SQL INNER JOIN clause?
Correct answer:
B) It returns records where there is a match between tables
Explanation: The INNER JOIN clause returns rows where there is a match between the two tables.
Which SQL function is used to return a portion of a string starting at a specific position?
Correct answer:
B) SUBSTRING()
Explanation: The SUBSTRING() function extracts a portion of a string based on the starting position and length.
Which SQL clause is used to filter records after the GROUP BY clause has been applied?
Correct answer:
C) HAVING
Explanation: The HAVING clause is used to filter records after the GROUP BY clause has been applied.
Which SQL statement is used to delete a table from a database?
Correct answer:
C) DROP TABLE
Explanation: The DROP TABLE statement is used to remove a table and all of its data from a database.
What does the SQL function COUNT() return?
Correct answer:
B) The number of rows
Explanation: The COUNT() function returns the total number of rows in a query result.
Which SQL function returns the current date and time?
Correct answer:
A) NOW()
Explanation: The NOW() function returns the current date and time.
What is the SQL clause used to specify the conditions for joining two tables?
Correct answer:
A) ON
Explanation: The ON clause is used to specify the condition for joining two tables in a JOIN operation.
Which SQL keyword is used to return only distinct values in a SELECT query?
Correct answer:
A) DISTINCT
Explanation: The DISTINCT keyword is used to return only unique values in a query result.
Which SQL function is used to return the average value of a column?
Correct answer:
A) AVG()
Explanation: The AVG() function calculates the average value of a numeric column.
How do you retrieve all rows where a column value is greater than or equal to 1000?
Correct answer:
B) WHERE Column >= 1000
Explanation: The >= operator is used to retrieve rows where a column value is greater than or equal to 1000.
Which SQL keyword is used to retrieve data from a database table?
Correct answer:
C) SELECT
Explanation: The SELECT keyword is used to retrieve data from a database table.
What is the SQL clause used to specify the number of rows to return in SQL Server?
Correct answer:
B) TOP
Explanation: The TOP clause is used in SQL Server to limit the number of rows returned.
Which SQL keyword is used to combine rows from two tables based on a related column?
Correct answer:
B) JOIN
Explanation: The JOIN keyword is used to combine rows from two tables based on a related column.
What SQL operator is used to test if two values are equal?
Correct answer:
B) =
Explanation: The = operator is used to test if two values are equal.
Which SQL function is used to find the maximum value in a column?
Correct answer:
A) MAX()
Explanation: The MAX() function returns the largest value in the selected column.
What SQL function is used to return the first non-NULL value from a set of arguments?
Correct answer:
B) COALESCE()
Explanation: The COALESCE() function returns the first non-NULL value from the arguments passed to it.
What does the SQL TRUNCATE statement do?
Correct answer:
A) It removes all rows from a table
Explanation: The TRUNCATE statement deletes all rows from a table but retains the table structure.
Which SQL function is used to concatenate two strings?
Correct answer:
A) CONCAT()
Explanation: The CONCAT() function concatenates two or more strings into one.
Which SQL operator is used to exclude rows that do not meet a condition?
Correct answer:
B) NOT
Explanation: The NOT operator is used to exclude rows that do not meet a specified condition.
How do you update a column value to NULL in a SQL table?
Correct answer:
A) UPDATE Table SET Column = NULL
Explanation: The correct way to set a column value to NULL is using UPDATE Table SET Column = NULL.
Which SQL function is used to remove trailing spaces from a string?
Correct answer:
B) RTRIM()
Explanation: The RTRIM() function removes trailing spaces from a string.
What SQL clause is used to restrict the number of rows returned in a query?
Correct answer:
B) LIMIT
Explanation: The LIMIT clause is used to specify the number of rows to return in a query.
Which SQL keyword removes duplicate rows from a query's result set?
Correct answer:
B) DISTINCT
Explanation: SELECT DISTINCT returns only unique combinations of the selected columns.
Which type of join returns all rows from the left table and the matching rows from the right table, with NULLs where there is no match?
Correct answer:
A) LEFT JOIN
Explanation: A LEFT (OUTER) JOIN keeps every row from the left table, filling right-table columns with NULL when no match exists.
Which statement adds a new column named email to an existing table named Customers?
Correct answer:
C) ALTER TABLE Customers ADD email VARCHAR(100);
Explanation: ALTER TABLE changes a table's structure. ADD creates a new column with the given data type.
If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.