This tutorial teaches you how to create
and run a DB2® SQL query by using
the SQL Query Builder, the visual interface for creating and running
SQL queries. For this tutorial, you will build a SELECT statement,
which includes a table alias, a column alias, a database function
expression, a CASE expression, and a grouping clause.
You will work with a DB2 database
called VIDEOS, that belongs to a fictional video store. The VIDEOS
database holds data related to store customers, inventory, video rentals,
and employees. The video store application that uses the VIDEOS database
needs a query that allows store employees to look up a particular
customer's rented video titles and the due dates. The query involves
two joins, a WHERE and GROUP BY clause, a CASE expression, a function,
and a host variable to substitute the name of the customer at runtime.
Learning objectives
Upon
successful completion of this tutorial, you should be able to:
- 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