Are you a SQL Master?

A modern workspace with a computer screen displaying SQL code, books on SQL and database design, a notepad, and coffee, capturing the essence of learning and mastering SQL.

Are You a SQL Master?

Test your SQL knowledge with our comprehensive quiz designed for all levels! Whether you're a beginner or an expert, challenge yourself with 50 carefully crafted questions that cover various aspects of SQL.

By taking this quiz, you’ll learn valuable information about:

  • Basic SQL commands
  • Advanced query techniques
  • Database management concepts
50 Questions12 MinutesCreated by QueryMaster482
What does SQL stand for?
Structured Question Language
Structured Query Language
Strong Question Language
Strong Query Language
Which SQL statement is used to update data in a database?
MODIFY
SAVE
UPDATE
SELECT
Which SQL statement is used to delete data from a database?
REMOVE
DELETE
DROP
ALTER
Which SQL statement is used to insert new data in a table?
INSERT
ADD
UPDATE
SET
How do you select a column named "FirstName" from a table named "Employees"?
EXTRACT FirstName from Employees
SELECT Employees.FirstName
GET FirstName FROM Employees
SELECT FirstName FROM Employees
How do you select all the records from a table named "Employees" where the value of the column "FirstName" is "Maria"?
SELECT * FROM Employees WHERE FirstName = 'Maria'
SELECT ALL FROM Employees WHERE FirstName = 'Maria'
SELECT * FROM Employees WHERE FirstName == 'Maria'
SELECT * FROM Employees WHERE FirstName <> 'Maria'
How do you select all the records from a table named "Employees" where the value of the column "FirstName" starts with an "a"?
SELECT * FROM Employees WHERE FirstName like '%a%'
SELECT * FROM Employees WHERE FirstName like 'a'
SELECT * FROM Employees WHERE FirstName like '%a'
SELECT * FROM Employees WHERE FirstName like 'a%'
The OR operator displays a record if ANY conditions listed are true.
True
False
The AND operator displays a record if ANY conditions listed are true.
True
False
Which SQL statement is used to return only different values?
ONLY
DIFFERENT
UNIQUE
DISTINCT
Which SQL keyword is used to sort the results of a query?
SORT
SORT BY
ORDER
ORDER BY
How can you return all the records of all columns in a table named "Sales" ordered from the biggest to the lowest sales? (column named "Value")"
SELECT * FROM Sales ORDER BY Value Asc
SELECT * FROM Sales ORDER BY Value Desc
SELECT * FROM Sales ORDER BY Sales Desc
SELECT Value FROM Sales ORDER BY Value Desc
How can you insert a new record into the "Employees" table, that has 3 columns: EmployeeID, FirstName, LastName?
INSERT INTO Employees VALUES (15, 'Jon', 'Smith')
SET Employees VALUES (15, 'Jon', 'Smith')
INSERT (15, 'Jon', 'Smith') INTO Employees
INSERT VALUES (15, 'Jon', 'Smith') INTO Employees
How can you insert "Jones" as the "LastName" in the "Employees" table, that has 3 columns: EmployeeID, FirstName, LastName?
INSERT INTO Employees VALUES ('Jones')
INSERT INTO Employees (LastName) VALUES ('Jones')
INSERT 'Jones' INTO Employees.LastName
INSERT 'Jones' INTO Employees (LastName)
How can you delete the records where the "FirstName" is "Ana" in the Employees Table?
DELETE 'Ana' FROM Employees.FirstName
DELETE 'Ana' FROM Employees
DELETE FROM Employees WHERE FirstName = 'Ana'
DELETE ROW FROM Employees WHERE FirstName = 'Ana'
How can you return the number of records in the "Employees" table?
SELECT LEN FROM Employees
SELECT COUNT FROM Employees
SELECT LEN(*) from Employees
SELECT COUNT(*) from Employees
Which operator is used to select values within a range?
BETWEEN
WITHIN
IN
RANGE
Which SQL statement is used to create a table named 'Customers'?
CREATE DATABASE TABLE 'Customers'
CREATE TABLE 'Customers'
SET TABLE = 'Customers'
CREATE TABLE 'Customers' IN [Database Name]
Which keyword is used to create a variable in a stored procedure?
UPDATE
INSERT
DECLARE
SET
Examine the following code. What is the function of the @productName?
Primary Key
Column name
Parameter
Table name
What is the purpose of a UNIQUE clause in a CREATE INDEX statement?
Replaces the values in the index key columns that are not unique by a new value
Ensures that the values in the index key columns are unique
Allow duplicated values in the index key columns
Delete the duplicated values in a table in which the index is being created
What is being indexed in the code above?
The column Employee
The whole table
The column EmployeeID
Nothing
What is a clustered Index?
An index in which logical order of index does not match physical stored order of the rows on disk
An index over grouped values of columns
An index in which table records are physically reordered to match the index
An index based on unique values of a column
What does CTE stand for in SQL?
Common Transformed Expression
Common Table Example
Create Table Expression
Common Table Expression
What is a CTE used for?
It works as a virtual table and helps simplify a query
It is a query result saved to the disk
To make a copy of an existing table
To make a join in a query
How can you create a view named "NorthCustomers" with the customers from "North" region in the table "Customers"?
CREATE VIEW FROM Customers WHERE Region = 'North' AS NorthCustomers
CREATE VIEW NorthCustomers AS SELECT * FROM Customers WHERE Region = 'North'
CREATE VIEW NorthCustomers AS SELECT * FROM Customers WHERE Region <> 'North'
CREATE NorthCustomers AS SELECT * FROM Customers WHERE Region = 'North'
What is a view in SQL?
An indexed table
A piece of code you can run based on a schedule
A virtual table based on the result of a query
The list of columns and column data types in a table
What is a Stored Procedure in SQL?
SQL code that you can save and reuse
A temporary copy of a table
A virtual table that can be used in a query
The result of a query that is saved
How do you create a Stored Procedure in SQL?
CREATE STORED PROCEDURE
CREATE PROCEDURE
SET PROCEDURE
DECLARE PROCEDURE
How do you execute a Stored Procedure?
RUN procedure_name
EXEC procedure_name
Procedure_name GO
PRINT procedure_name
Which of the following functions extracts a number of characters from the start of a string?
LEFT TRIM()
LTRIM()
RIGHT()
LEFT()
Which of the following queries would retrieve the column “country”, and a second column where the values “CA” in that column change to “Canada”, in a table named “customers”?
SELECT country, REPLACE(country, 'CA', 'Canada') AS new_country FROM customers
SELECT country, REPLACE(country, 'Canada', 'CA') AS new_country FROM customers
SELECT country REPLACE(country, 'CA', 'Canada') AS new_country FROM customers
SELECT REPLACE(country, 'CA', 'Canada') AS new_country FROM customers
Which of the following is NOT one of the TRIM functions?
RTRIM
LTRIM
LEFT TRIM
TRIM
What is the purpose of SUBSTRING in SQL?
To extract a string with a specified length starting from a given location in an input string
To join strings together
To append strings together
To remove white spaces from the beginning or the end of a string
Which of the following can be used to join or concatenate two strings?
CONCATENATE()
JOIN()
CONCAT()
AND
Which of the following is a function that converts all characters in the specified string to uppercase?
UPPERCASE()
UPPER()
CASE()
UP()
Which of the following is a function that removes blank characters only from the left side of a string?
LEFT()
LTRIM()
TRIM()
LEFTTRIM()
What does the STRING_AGG() function do?
Aggregates the values of 2 columns
Joins columns into a single string separated by a specified separator
Joins rows of strings into a single string separated by a specified separator
Groups all lines with the same value in one
Can the COALESCE() function be used to handle NULL values?
True
False
Aggregate functions in SQL are:
User-defined functions
Built-in functions
What will be the output of the following query?
 
SELECT name, age, CONCAT(name, ': ', age, ' years') AS name_age
FROM customers
The query above retrieves the name and age of all customers. Then, it creates a new column called name_age that joins the customer's age (in years) to the names of customers separated by a colon (:) from the customers table
The query above retrieves the name and age of all customers. Then, it creates a new column called name_age that joins the customer's name to the age (in years) separated by a colon (:) from the customers table
The query above retrieves the name of all customers and a new column called name_age that joins the customer's name and age (in years) separated by a colon (:) from the customers table
The query above retrieves the age of all customers and a new column called name_age that joins the customer's name and age (in years) separated by a colon (:) from the customers table
Which of the following queries retrieves the customer_name, and replace a missing country with the city, state or N/A for all customers in the state of California?
SELECT customer_name, COALESCE(country, city, state, 'N/A') FROM customers WHERE state = 'California'
SELECT COALESCE(country, city, state, 'N/A') FROM customers WHERE state = 'California'
SELECT COALESCE(country, city, state, 'N/A') AS customer_name FROM customers WHERE state = 'California'
SELECT customer_name, REPLACE(country, city, state, 'N/A') FROM customers WHERE state = 'California'
Which of the following can a subquery return?
A single row
A single column
An entire table
All of the above
Which of the following queries would retrieve a list of all managers who became managers after the 1st of January 1990 and are not in the Finance or HR department?
 
Departments table:
Picture1
 
Department managers (dept_manager) table:
Picture2
SELECT * FROM dept_manager WHERE from_date > '1990-01-01' AND dept_no NOT IN (SELECT dept_no FROM departments WHERE dept_name IN ('Finance','HR'))
SELECT * FROM dept_manager WHERE from_date > '1990-01-01' AND dept_no IN (SELECT dept_no FROM departments WHERE dept_name IN ('Finance','Human Resources'))
SELECT * FROM dept_manager WHERE from_date > '1990-01-01' AND dept_no NOT IN (SELECT dept_name FROM departments WHERE dept_name NOT IN ('Finance','Human Resources'))
SELECT * FROM dept_manager WHERE from_date > '1990-01-01' AND dept_no NOT IN (SELECT dept_no FROM departments WHERE dept_name IN ('Finance','Human Resources'))
Which operator tests membership in a collection of values produced by a SELECT? clause?
OR
AND
IN
NOT IN
Which type of join returns a subset of data common to both tables?
LEFT JOIN
RIGHT JOIN
INNER JOIN
FULL JOIN
What is the keyword ON used for in a SQL join?
To define a filter on the subset of data returned
To identify which columns link the two tables
To return only distinct values
To present the results by a specific order
Which type of join returns all the data of both table, whether they match or not?
LEFT JOIN
RIGHT JOIN
INNER JOIN
FULL JOIN
How can you return all the information of two or more tables with the same structure/columns in a single table, keeping that same structure/columns?
CONCAT
UNION ALL
JOIN
APPEND
How can you return the information of two or more tables with the same structure/columns in a single table, keeping that same structure/columns but removing duplicated lines?
UNION
UNION ALL
JOIN
APPEND
{"name":"Are you a SQL Master?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your SQL knowledge with our comprehensive quiz designed for all levels! Whether you're a beginner or an expert, challenge yourself with 50 carefully crafted questions that cover various aspects of SQL.By taking this quiz, you’ll learn valuable information about:Basic SQL commandsAdvanced query techniquesDatabase management concepts","img":"https:/images/course8.png"}
Powered by: Quiz Maker