This tutorial teaches you how to create
and run a DB2® SQL query. Using
the SQL Query Builder, which is a visual interface for
creating and running SQL queries, you will build a SELECT statement.
The statement will include a table alias, a column alias, a database
function expression, a CASE expression, and a grouping clause.
You will work with a DB2 database
for a video store called VIDEOS. The database holds data that is related
to the store customers, inventory, video rentals, and employees. The
video store application needs a query that lets the store employees
look up the video titles that a particular customer has rented and
what day of the week the videos are due. The query involves two joins,
a query condition (WHERE clause), and a GROUP BY clause. The DB2 SQL statement also needs a CASE
expression, a function, and a host variable to substitute the name
of the customer at run time.
Learning objectives
When
you complete the exercises, you will know how to do the following
tasks:
- Create a SELECT statement
- Add tables to the statement
- Add table aliases
- Specify result columns
- Add a CASE expression to the result column set
- Add a column alias
- Join tables
- Create a query condition
- Add a GROUP BY clause
- Run the DB2 SQL query and
pass in a host variable for the query
This tutorial should take approximately 30 minutes to
finish. If you explore other concepts related to this tutorial, it
could take longer to complete.
Skill level
Beginner
Audience
Database application developers