This Quiz contains totally 30 Questions each carry 1 point for you.
Which SQL statement is used to retrieve data from a database?
GET
OPEN
SELECT
RETRIEVE
Correct!
Wrong!
Which SQL clause is used to filter records?
WHERE
FILTER
GROUP BY
SORT
Correct!
Wrong!
Which SQL keyword is used to sort the result-set?
SORT
ORDER BY
ARRANGE
GROUP BY
Correct!
Wrong!
What is the correct SQL statement to return the unique values in a column?
SELECT UNIQUE
SELECT DISTINCT
SELECT DIFFERENT
SELECT SEPARATE
Correct!
Wrong!
Which SQL statement is used to add a new row in a table?
ADD ROW
INSERT INTO
ADD RECORD
INSERT NEW
Correct!
Wrong!
Which SQL statement is used to remove a table and its data?
REMOVE TABLE
DELETE TABLE
DROP TABLE
ERASE TABLE
Correct!
Wrong!
Which SQL statement is used to combine data from two tables?
JOIN
COMBINE
UNION
MERGE
Correct!
Wrong!
How do you return the first name and last name of all employees in a table called "Employees"?
SELECT first_name, last_name FROM Employees
SELECT name FROM Employees
SELECT first_name AND last_name FROM Employees
SELECT first_name last_name FROM Employees
Correct!
Wrong!
Which SQL function is used to add a column to a table?
ADD COLUMN
INSERT COLUMN
ALTER TABLE
MODIFY TABLE
Correct!
Wrong!
Which operator is used to search for a specified pattern in a column?
LIKE
PATTERN
SEARCH
FIND
Correct!
Wrong!
What is the default sorting order in SQL?
DESC
ASC
DEFAULT
NONE
Correct!
Wrong!
How do you select the top 5 records from a table?
SELECT TOP 5 * FROM table_name
SELECT * FROM table_name LIMIT 5
SELECT FIRST 5 * FROM table_name
SELECT * FROM table_name TOP 5
Correct!
Wrong!
What keyword is used to retrieve records within a specific range?
BETWEEN
WITHIN
LIMIT
RANGE
Correct!
Wrong!
Which of the following is a DDL command?
SELECT
INSERT
CREATE
UPDATE
Correct!
Wrong!
What does the SQL IN operator do?
Checks if a value matches any value in a list
Checks if a value is within a specified range
Checks if a value is not null
Checks if a value is unique
Correct!
Wrong!
How do you rename a column in a table?
RENAME COLUMN column_name TO new_name
ALTER TABLE table_name RENAME COLUMN column_name TO new_name
MODIFY TABLE table_name RENAME COLUMN column_name TO new_name
CHANGE COLUMN column_name TO new_name
Correct!
Wrong!
What is the purpose of the SQL HAVING clause?
Filter records after an aggregation
Filter records before an aggregation
Group records
Sort records
Correct!
Wrong!
How do you find the second highest salary from the "Employees" table?
SELECT MAX(salary) FROM Employees WHERE salary < (SELECT MAX(salary) FROM Employees)
SELECT salary FROM Employees ORDER BY salary DESC LIMIT 1 OFFSET 1
SELECT salary FROM Employees ORDER BY salary ASC LIMIT 1 OFFSET 1
SELECT MAX(salary) FROM Employees WHERE salary != (SELECT MAX(salary) FROM Employees)
Correct!
Wrong!
UPDATE Employees SET email = 'newemail@example.com' WHERE id = 10
B) MODIFY Employees SET email = 'newemail@example.com' WHERE id = 10
C) SET email = 'newemail@example.com' WHERE id = 10 IN Employees
D) CHANGE email TO 'newemail@example.com' WHERE id = 10
Correct!
Wrong!
How do you delete all rows where the "status" is 'inactive' in the "Users" table?
REMOVE FROM Users WHERE status = 'inactive'
DELETE FROM Users WHERE status = 'inactive'
DROP FROM Users WHERE status = 'inactive'
ERASE FROM Users WHERE status = 'inactive'
Correct!
Wrong!
How do you retrieve the number of employees in each department?
SELECT department, COUNT(*) FROM Employees GROUP BY department
SELECT department, SUM(*) FROM Employees GROUP BY department
SELECT department, COUNT() FROM Employees GROUP BY department
SELECT department, TOTAL(*) FROM Employees GROUP BY department
Correct!
Wrong!
How do you find all employees whose names start with the letter 'A'?
SELECT * FROM Employees WHERE name LIKE 'A%'
SELECT * FROM Employees WHERE name LIKE '%A'
SELECT * FROM Employees WHERE name LIKE '_A%'
SELECT * FROM Employees WHERE name LIKE '%A%'
Correct!
Wrong!
How do you add a new column "birthdate" of type DATE to the "Employees" table?
ALTER TABLE Employees ADD COLUMN birthdate DATE
MODIFY TABLE Employees ADD birthdate DATE
ADD COLUMN birthdate DATE TO Employees
CHANGE TABLE Employees ADD COLUMN birthdate DATE
Correct!
Wrong!
How do you calculate the average salary of employees in the "HR" department?
SELECT AVG(salary) FROM Employees WHERE department = 'HR'
SELECT MEAN(salary) FROM Employees WHERE department = 'HR'
SELECT AVERAGE(salary) FROM Employees WHERE department = 'HR'
SELECT MEDIAN(salary) FROM Employees WHERE department = 'HR'
Correct!
Wrong!
How do you join the "Orders" table with the "Customers" table on the "customer_id" field?
SELECT * FROM Orders JOIN Customers ON Orders.customer_id = Customers.id
SELECT * FROM Orders INNER JOIN Customers ON Orders.customer_id = Customers.id
SELECT * FROM Orders LEFT JOIN Customers ON Orders.customer_id = Customers.id
SELECT * FROM Orders RIGHT JOIN Customers ON Orders.customer_id = Customers.id
Correct!
Wrong!
How do you retrieve records where the "price" is between 100 and 200 in the "Products" table?
SELECT * FROM Products WHERE price BETWEEN 100 AND 200
SELECT * FROM Products WHERE price > 100 AND price < 200
SELECT * FROM Products WHERE price > 100 AND price < 200
SELECT * FROM Products WHERE price IN RANGE 100 TO 200
Correct!
Wrong!
How do you find the total sales amount from the "Sales" table?
SELECT SUM(amount) FROM Sales
SELECT TOTAL(amount) FROM Sales
SELECT ADD(amount) FROM Sales
SELECT TOTAL_SALES(amount) FROM Sales .
Correct!
Wrong!
How do you list all tables in the current database?
SHOW TABLES
LIST TABLES
DISPLAY TABLES
DESCRIBE TABLES
Correct!
Wrong!
How do you retrieve records from the "Employees" table where the "hire_date" is in the last 30 days?
SELECT * FROM Employees WHERE hire_date >= CURDATE() - INTERVAL 30 DAY
SELECT * FROM Employees WHERE hire_date >= DATE() - 30
SELECT * FROM Employees WHERE hire_date >= NOW() - 30
SELECT * FROM Employees WHERE hire_date >= TODAY() - 30
Correct!
Wrong!
Which SQL statement is used to remove data from a database?
REMOVE
DELETE
ERASE
CLEAR
Correct!
Wrong!
Share the quiz to show your results !
Subscribe to see your results
MY SQL – Quiz
You got %%score%% of %%total%% right
%%description%%
%%description%%
Loading...
