Create a DB2 SQL query

This tutorial teaches you how to create and run a DB2® SQL query by using the SQL Query Builder. It helps you build a SELECT statement that includes a table alias, a column alias, a database function expression, a CASE expression, and a grouping clause.

The tutorial uses a DB2 database that is called VIDEOS. The VIDEOS database holds data that is related to video store customers, inventory, video rentals, and employees. The tutorial helps you create a query that allows store employees to look up a particular customer's rented video titles and the due dates. The query includes the following elements:
  • Two joins
  • A WHERE and GROUP BY clause
  • A CASE expression
  • A function
  • A host variable to substitute the name of the customer at run time

Learning objectives

This tutorial teaches you 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 takes approximately 30 minutes to finish. If you explore other concepts that are related to this tutorial, it can take longer to complete.

Skill level

Beginner

Audience

Database application developers