MCQs on Querying Data with SELECT Statements | Data Retrieval

1. Basic SELECT Queries (SELECT, FROM, WHERE)

  1. Which SQL statement is used to select data from a database?
    a) GET
    b) SELECT
    c) RETRIEVE
    d) FETCH
  2. Which clause is used to specify the table from which to retrieve data in SQL?
    a) SELECT
    b) FROM
    c) WHERE
    d) ORDER BY
  3. What is the correct SQL syntax to fetch data from a column named “Age” in a table called “Employees”?
    a) SELECT Age FROM Employees;
    b) GET Age FROM Employees;
    c) SELECT FROM Age Employees;
    d) SHOW Age FROM Employees;
  4. Which of the following SQL statements will return all records from the “Customers” table where the “Country” is “USA”?
    a) SELECT * FROM Customers WHERE Country = ‘USA’;
    b) SELECT * FROM Customers WHERE ‘Country’ = USA;
    c) SELECT * FROM Customers WHERE Country == ‘USA’;
    d) SELECT * FROM Customers WHERE Country = USA;
  5. Which keyword is used to filter records in SQL?
    a) FILTER
    b) WHERE
    c) ORDER
    d) SELECT

2. Filtering and Sorting Data with WHERE and ORDER BY

  1. How can you retrieve all customers who live in “New York” from the “Customers” table?
    a) SELECT * FROM Customers WHERE City = ‘New York’;
    b) SELECT * FROM Customers WHERE City == ‘New York’;
    c) SELECT * FROM Customers WHERE City = “New York”;
    d) SELECT * FROM Customers WHERE New York = City;
  2. What SQL clause is used to sort the results in ascending order?
    a) ORDER
    b) SORT
    c) ORDER BY
    d) GROUP BY
  3. Which SQL statement will return a list of products sorted by price in descending order?
    a) SELECT * FROM Products ORDER BY Price DESC;
    b) SELECT * FROM Products ORDER Price DESC;
    c) SELECT * FROM Products ORDER DESC Price;
    d) SELECT * FROM Products SORT Price DESC;
  4. What will the following SQL query return? SELECT * FROM Customers WHERE Age > 30 AND City = ‘Los Angeles’;
    a) All customers who are older than 30 and live in Los Angeles
    b) All customers who are younger than 30 and live in Los Angeles
    c) All customers who live in Los Angeles
    d) All customers who are older than 30
  5. Which clause is used to sort the result set in SQL?
    a) SORT
    b) ORDER BY
    c) GROUP BY
    d) SELECT

3. Using DISTINCT, GROUP BY, and HAVING Clauses

  1. Which SQL statement is used to remove duplicates from the result set?
    a) REMOVE
    b) DISTINCT
    c) UNIQUE
    d) DELETE
  2. What does the following SQL query do? SELECT DISTINCT Country FROM Customers;
    a) Retrieves all customers’ countries, including duplicates
    b) Retrieves all unique countries from the “Customers” table
    c) Retrieves all customer names
    d) Retrieves the number of countries in the “Customers” table
  3. Which clause is used in SQL to group rows that have the same values into summary rows?
    a) ORDER BY
    b) GROUP BY
    c) HAVING
    d) JOIN
  4. What does the HAVING clause do in SQL?
    a) Filters records before the grouping of rows
    b) Filters records after the grouping of rows
    c) Joins tables together
    d) Sorts the records in ascending order
  5. Which SQL query will return the total number of customers for each country?
    a) SELECT Country, COUNT(CustomerID) FROM Customers GROUP BY Country;
    b) SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country;
    c) SELECT Country, COUNT(CustomerID) FROM Customers;
    d) SELECT COUNT(CustomerID) FROM Customers GROUP BY Country;

4. Aliases and Column Formatting

  1. Which SQL statement is used to assign an alias to a column in the result set?
    a) AS
    b) ALIAS
    c) COLUMN
    d) SET
  2. What will be the result of the following SQL query? SELECT Name AS ‘Employee Name’ FROM Employees;
    a) The column will be renamed as ‘Employee Name’ in the result set
    b) The column will be renamed as ‘Name’
    c) It will return an error
    d) It will return all employee names but without the column name
  3. How would you rename the “Age” column to “Employee Age” in the result set using SQL?
    a) SELECT Age AS ‘Employee Age’ FROM Employees;
    b) SELECT Age ‘Employee Age’ FROM Employees;
    c) SELECT ‘Employee Age’ AS Age FROM Employees;
    d) SELECT AS ‘Employee Age’ FROM Age Employees;
  4. Which SQL query is correct for selecting a column with a custom alias?
    a) SELECT COUNT() AS TotalEmployees FROM Employees;
    b) SELECT COUNT(
    ) FROM Employees AS TotalEmployees;
    c) SELECT COUNT() AS TotalEmployees FROM Employees;
    d) SELECT TotalEmployees FROM COUNT(*) Employees;
  5. Which clause is used to format column names with an alias in SQL?
    a) AS
    b) ALIAS
    c) LABEL
    d) RENAME

5. Aggregation Functions (SUM, AVG, COUNT, etc.)

  1. Which SQL function is used to calculate the sum of a numeric column?
    a) ADD
    b) SUM
    c) TOTAL
    d) CALCULATE
  2. What is the result of the following SQL query? SELECT AVG(Salary) FROM Employees;
    a) The total salary of all employees
    b) The average salary of all employees
    c) The highest salary of an employee
    d) The number of employees in the company
  3. Which SQL function returns the number of rows in a result set?
    a) COUNT
    b) SUM
    c) AVG
    d) MAX
  4. Which function would you use to find the highest value in a column?
    a) MAX
    b) MIN
    c) TOP
    d) HIGH
  5. Which of the following SQL functions can be used to find the lowest value in a column?
    a) MIN
    b) LOW
    c) LEAST
    d) LOWEST
  6. Which SQL query would return the total sales for all orders from the “Orders” table?
    a) SELECT SUM(SalesAmount) FROM Orders;
    b) SELECT SUM(SalesAmount) AS TotalSales FROM Orders;
    c) SELECT TOTAL(SalesAmount) FROM Orders;
    d) SELECT COUNT(SalesAmount) FROM Orders;
  7. What will the following query do? SELECT COUNT(CustomerID) FROM Customers WHERE Country = ‘USA’;
    a) Count the number of customers in the “Customers” table
    b) Count the number of customers from the USA
    c) Count the number of countries in the “Customers” table
    d) Count the number of orders from the USA
  8. How can you find the average age of employees from the “Employees” table?
    a) SELECT AVG(Age) FROM Employees;
    b) SELECT AVERAGE(Age) FROM Employees;
    c) SELECT SUM(Age) FROM Employees;
    d) SELECT COUNT(Age) FROM Employees;
  9. Which SQL function would you use to count the number of unique products in an “Orders” table?
    a) COUNT(DISTINCT ProductID)
    b) COUNT(ProductID)
    c) DISTINCT(ProductID)
    d) SUM(ProductID)
  10. Which function will return the average salary of employees in a department called ‘HR’?
    a) SELECT AVG(Salary) FROM Employees WHERE Department = ‘HR’;
    b) SELECT SUM(Salary) FROM Employees WHERE Department = ‘HR’;
    c) SELECT AVG(Salary) FROM HR;
    d) SELECT AVERAGE(Salary) FROM Employees WHERE Department = ‘HR’;

Answer Table

QnoAnswer (Option with the text)
1b) SELECT
2b) FROM
3a) SELECT Age FROM Employees;
4a) SELECT * FROM Customers WHERE Country = ‘USA’;
5b) WHERE
6a) SELECT * FROM Customers WHERE City = ‘New York’;
7c) ORDER BY
8a) SELECT * FROM Products ORDER BY Price DESC;
9a) All customers who are older than 30 and live in Los Angeles
10b) ORDER BY
11b) DISTINCT
12b) Retrieves all unique countries from the “Customers” table
13b) GROUP BY
14b) Filters records after the grouping of rows
15a) SELECT Country, COUNT(CustomerID) FROM Customers GROUP BY Country;
16a) AS
17a) The column will be renamed as ‘Employee Name’ in the result set
18a) SELECT Age AS ‘Employee Age’ FROM Employees;
19a) SELECT COUNT(*) AS TotalEmployees FROM Employees;
20a) AS
21b) SUM
22b) The average salary of all employees
23a) COUNT
24a) MAX
25a) MIN
26b) SELECT SUM(SalesAmount) AS TotalSales FROM Orders;
27b) Count the number of customers from the USA
28a) SELECT AVG(Age) FROM Employees;
29a) COUNT(DISTINCT ProductID)
30a) SELECT AVG(Salary) FROM Employees WHERE Department = ‘HR’;

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top