SQL SELECT Statement Practice Questions with Solutions

The SELECT statement is one of the most important SQL commands because it is used to retrieve data from one or more database tables.

Whether you are a Data Analyst, SQL Developer, Backend Developer, or Database Administrator, you will use the SELECT statement almost every day.

The SELECT statement allows you to:

  • Retrieve all records from a table
  • Retrieve specific columns
  • Remove duplicate records
  • Rename columns
  • Perform calculations
  • Display formatted results

Mastering the SELECT statement is the first step toward writing advanced SQL queries involving filtering, sorting, grouping, joins, and subqueries. SQL SELECT Statement practice questions with solutions help to understand the concepts.


What is the SQL SELECT Statement?

The SELECT statement is used to retrieve data from a database table.

Basic Syntax

SELECT column_name

FROM table_name;

If you want to retrieve all columns, use the * wildcard.

SELECT *

FROM table_name;

Sample Table Used Throughout This Chapter

students

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

Why is the SELECT Statement Important?

The SELECT statement helps users:

  • View stored data
  • Generate reports
  • Analyze business information
  • Create dashboards
  • Export data
  • Filter and sort records
  • Perform calculations

Almost every SQL query begins with the SELECT keyword.


General Syntax Variations

Retrieve all columns:

SELECT *

FROM students;

Retrieve specific columns:

SELECT name,

marks

FROM students;

Retrieve multiple columns:

SELECT id,

name,

course

FROM students;

1. SQL Query to Retrieve All Student Records

Problem Statement

Write an SQL query to display all records from the students table.

SQL Solution

SELECT *

FROM students;

Sample Output

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

Explanation

The * wildcard instructs SQL to return every column from the specified table.

This is useful when:

  • Checking table contents
  • Debugging
  • Learning SQL

Concepts Covered

  • SELECT
  • Wildcard (*)
  • Retrieve All Columns

2. SQL Query to Retrieve Student Names

Problem Statement

Write an SQL query to display only the student names.

SQL Solution

SELECT name

FROM students;

Sample Output

name
Rahul
Amit
Neha
Priya
Rohit

Explanation

Instead of retrieving all columns, SQL allows you to retrieve only the required column.

Selecting fewer columns improves query performance.

Concepts Covered

  • SELECT Statement
  • Single Column Selection
  • Data Retrieval

3. SQL Query to Retrieve Student Name and Course

Problem Statement

Write an SQL query to display each student’s name and course.

SQL Solution

SELECT name,

course

FROM students;

Sample Output

namecourse
RahulPython
AmitJava
NehaSQL
PriyaPython
RohitJava

Explanation

Multiple columns can be retrieved by separating them with commas.

Only the specified columns appear in the result.

Concepts Covered

  • Multiple Columns
  • SELECT Statement
  • SQL Basics

4. SQL Query to Retrieve Student ID, Name, and Marks

Problem Statement

Write an SQL query to display the Student ID, Student Name, and Marks from the students table.

Sample Table

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

SQL Solution

SELECT id,
       name,
       marks

FROM students;

Sample Output

idnamemarks
101Rahul88
102Amit91
103Neha95
104Priya84
105Rohit90

Explanation

This query retrieves only the id, name, and marks columns from the table.

Instead of displaying every column, SQL returns only the requested information.

Selecting fewer columns:

  • Improves readability
  • Reduces unnecessary data transfer
  • Makes reports more efficient

Concepts Covered

  • SELECT Statement
  • Multiple Column Selection
  • Data Retrieval
  • SQL Basics

5. SQL Query to Retrieve Student City and Course

Problem Statement

Write an SQL query to display the City and Course of every student.


Sample Table

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

SQL Solution

SELECT city,
       course

FROM students;

Sample Output

citycourse
DelhiPython
NoidaJava
DelhiSQL
GurgaonPython
FaridabadJava

Explanation

The SELECT statement retrieves the city and course columns from the table.

Notice that Delhi appears twice because the SELECT statement does not remove duplicate values automatically.

To remove duplicates, the DISTINCT keyword is used, which will be covered later in this chapter.


Concepts Covered

  • SELECT Statement
  • Multiple Columns
  • Duplicate Values
  • SQL Data Retrieval

6. SQL Query to Retrieve All Columns in a Different Order

Problem Statement

Write an SQL query to display the columns in the following order:

  • Name
  • Course
  • City
  • Marks
  • Age
  • ID

Sample Table

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

SQL Solution

SELECT name,
       course,
       city,
       marks,
       age,
       id

FROM students;

Sample Output

namecoursecitymarksageid
RahulPythonDelhi8821101
AmitJavaNoida9122102
NehaSQLDelhi9520103
PriyaPythonGurgaon8423104
RohitJavaFaridabad9021105

Explanation

The order of columns returned by SQL depends entirely on the order specified in the SELECT statement.

Changing the order in the query does not change the table structure in the database.

This feature is useful when creating reports or exporting data.


Concepts Covered

  • Column Ordering
  • SELECT Statement
  • SQL Reports

7. SQL Query Using Column Aliases (AS)

Problem Statement

Write an SQL query to display Student Name and Student Marks using meaningful column aliases.


Sample Table

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

SQL Solution

SELECT name AS Student_Name,
       marks AS Student_Marks

FROM students;

Sample Output

Student_NameStudent_Marks
Rahul88
Amit91
Neha95
Priya84
Rohit90

Explanation

The AS keyword assigns a temporary name (alias) to a column in the query result.

Aliases improve readability and are commonly used in:

  • Reports
  • Dashboards
  • Data Analysis
  • Business Intelligence

The original database table remains unchanged.


Concepts Covered

  • AS Keyword
  • Column Alias
  • SQL Formatting

8. SQL Query Using Table Aliases

Problem Statement

Write an SQL query using a table alias to display student names and cities.


Sample Table

idnameagecoursecitymarks
101Rahul21PythonDelhi88
102Amit22JavaNoida91
103Neha20SQLDelhi95
104Priya23PythonGurgaon84
105Rohit21JavaFaridabad90

SQL Solution

SELECT s.name,
       s.city

FROM students AS s;

Sample Output

namecity
RahulDelhi
AmitNoida
NehaDelhi
PriyaGurgaon
RohitFaridabad

Explanation

A table alias assigns a temporary name to a table.

Instead of writing:

students.name

you can write:

s.name

Table aliases make SQL queries shorter and easier to understand, especially when working with joins or multiple tables.


Concepts Covered

  • Table Alias
  • AS Keyword
  • Query Simplification
  • SQL Readability

9. SQL Query to Display a Constant Value

Problem Statement

Write an SQL query to display a constant text message.


SQL Solution

SELECT 'Welcome to SQL Practice' AS Message;

Sample Output

Message
Welcome to SQL Practice

Explanation

SQL can return constant values without accessing any database table.

This is useful for:

  • Testing SQL syntax
  • Displaying messages
  • Understanding how the SELECT statement works

Concepts Covered

  • SELECT Statement
  • Constant Values
  • AS Keyword

10. SQL Query Using Mathematical Expressions

Problem Statement

Write an SQL query to calculate the total of two numbers.


SQL Solution

SELECT 500 + 250 AS Total;

Sample Output

Total
750

Explanation

SQL supports arithmetic operations directly in the SELECT statement.

Common arithmetic operators include:

  • + (Addition)
  • - (Subtraction)
  • * (Multiplication)
  • / (Division)
  • % (Modulus, supported in many databases)

These expressions can be used with constants or table columns.


Concepts Covered

  • Arithmetic Expressions
  • SQL Operators
  • Mathematical Calculations
  • SELECT Statement

11. SQL Query to Display the Current Date

Problem Statement

Write an SQL query to display the current system date.


SQL Solution (MySQL)

SELECT CURDATE() AS Current_Date;

Sample Output

Current_Date
2026-08-08

Note: The displayed date depends on the current date of your MySQL server.


Explanation

The CURDATE() function returns the current system date in the format:

YYYY-MM-DD

This function is commonly used in:

  • Attendance Management Systems
  • Payroll Applications
  • Order Management Systems
  • Reporting Dashboards

Concepts Covered

  • CURDATE()
  • Date Functions
  • SQL Functions

12. SQL Query to Display the Current Time

Problem Statement

Write an SQL query to display the current system time.


SQL Solution (MySQL)

SELECT CURTIME() AS Current_Time;

Sample Output

Current_Time
13:45:27

Note: The displayed time depends on your database server’s current time.


Explanation

The CURTIME() function returns only the current system time.

Format:

HH:MM:SS

It is useful for:

  • Login Systems
  • Attendance Applications
  • Time Tracking
  • Audit Logs

Concepts Covered

  • CURTIME()
  • SQL Time Functions
  • SQL Functions

13. SQL Query to Display the Current Date and Time

Problem Statement

Write an SQL query to display the current date and time together.


SQL Solution (MySQL)

SELECT NOW() AS Current_Date_Time;

Sample Output

Current_Date_Time
2026-08-08 13:45:27

Note: The actual output depends on the current date and time of your MySQL server.


Explanation

The NOW() function returns both the current date and current time.

It is frequently used in:

  • Logging Systems
  • User Registration
  • Order Tracking
  • Activity Monitoring

Concepts Covered

  • NOW()
  • Date & Time Functions
  • SQL Functions

14. SQL Query to Display the Current Database

Problem Statement

Write an SQL query to display the name of the currently selected database.


SQL Solution (MySQL)

SELECT DATABASE() AS Current_Database;

Sample Output

Current_Database
studentdb

Note: The returned database name depends on the database currently selected in your SQL session.


Explanation

The DATABASE() function returns the name of the active database.

This function is useful when working with multiple databases to verify which database is currently in use.


Concepts Covered

  • DATABASE()
  • Database Functions
  • SQL Environment

15. SQL Query to Display the Database Version

Problem Statement

Write an SQL query to display the version of the MySQL database server.


SQL Solution (MySQL)

SELECT VERSION() AS Database_Version;

Sample Output

Database_Version
8.0.xx

Note: The exact version number depends on the installed MySQL server.


Explanation

The VERSION() function returns the version of the connected database server.

This information helps developers verify compatibility with SQL features and database updates.


Concepts Covered

  • VERSION()
  • Database Information
  • SQL Functions

Chapter Summary

In this chapter, you learned one of the most important SQL commands—the SELECT statement. The SELECT statement is used to retrieve data from one or more tables and forms the foundation of almost every SQL query.

You explored how to retrieve all columns, select specific columns, reorder columns, use column aliases and table aliases, perform arithmetic expressions, and work with built-in SQL functions such as CURDATE(), CURTIME(), NOW(), DATABASE(), and VERSION().

These concepts are essential before moving on to filtering records using the WHERE clause in the next chapter.

Throughout this chapter, you covered:

  • SELECT Statement
  • Retrieving All Columns
  • Retrieving Specific Columns
  • Multiple Column Selection
  • Column Ordering
  • Column Aliases (AS)
  • Table Aliases (AS)
  • Constant Values
  • Arithmetic Expressions
  • Date Functions
  • Time Functions
  • Database Functions
  • Version Functions

Mastering the SELECT statement will help you write efficient SQL queries and build a strong foundation for advanced SQL concepts such as filtering, sorting, grouping, joins, and subqueries.


Key Takeaways

  • The SELECT statement retrieves data from database tables.
  • SELECT * returns all columns from a table.
  • Selecting only required columns improves query performance.
  • Column aliases improve the readability of query results.
  • Table aliases simplify complex SQL queries.
  • SQL supports arithmetic expressions directly within the SELECT statement.
  • CURDATE() returns the current date.
  • CURTIME() returns the current time.
  • NOW() returns both the current date and time.
  • DATABASE() and VERSION() provide useful database information.

Frequently Asked Questions (FAQs)

1. What is the SQL SELECT statement?

The SELECT statement is used to retrieve data from one or more database tables.

Example:

SELECT *

FROM students;

2. What does SELECT * mean?

The * wildcard instructs SQL to retrieve every column from the specified table.

Example:

SELECT *

FROM employees;

3. Why should I select only required columns?

Selecting only the required columns:

  • Improves performance
  • Reduces data transfer
  • Makes reports easier to read
  • Optimizes large database queries

Example:

SELECT name,

salary

FROM employees;

4. What is a column alias?

A column alias provides a temporary name to a column in the query result.

Example:

SELECT marks AS Student_Marks

FROM students;

The original table structure remains unchanged.


5. What is a table alias?

A table alias gives a temporary name to a table.

Example:

SELECT s.name

FROM students AS s;

Table aliases improve readability, especially when working with joins.


6. Can SQL perform calculations?

Yes.

Example:

SELECT 50 * 20 AS Result;

Output:

1000

SQL supports addition, subtraction, multiplication, and division.


7. What is the difference between CURDATE() and NOW()?

CURDATE()

Returns only the current date.

Example:

2026-08-08

NOW()

Returns both the current date and current time.

Example:

2026-08-08 14:15:20

8. Where is the SQL SELECT statement used in real-world applications?

The SELECT statement is used in almost every database application, including:

  • Banking Systems
  • Hospital Management Systems
  • Student Management Systems
  • E-commerce Websites
  • Inventory Management
  • CRM Software
  • Business Intelligence Dashboards
  • Reporting Tools
  • Data Analytics
  • ERP Systems

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top