DB2 SQL Workshop (Course Code CF12)

Size: px
Start display at page:

Download "DB2 SQL Workshop (Course Code CF12)"

Transcription

1 DB2 SQL Workshop (Course Code CF12) Instructor Exercises Guide ERC3.0 IBM Learning Services Worldwide Certified Material

2 Publishing Information This publication has been produced using BookMaster (Program Number ), the Document Composition Facility (Program Number 5748-XX9), and Freelance 97 for Windows. It was printed on the IBM 3820 Page Printer. Trademarks IBM is a registered trademark of International Business Machines Corporation. The following are trademarks International Business Machines Corporation in the United States, or other countries, or both: BookMaster DB2 OS/390 QMF Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. UNIX is a registered trademark in the United States and other countries licensed exclusively through The Open Group. Other company, product, and service names may be trademarks or service marks of others. December, 2000 The information contained in this document has not been submitted to any formal IBM test and is distributed on an as is basis without any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. While each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will result elsewhere. Customers attempting to adapt these techniques to their own environments do so at their own risk. The original repository material for this course has been certified as being Year 2000 compliant. Copyright International Business Machines Corporation 1999, All rights reserved. This document may not be reproduced in whole or in part Note to U.S. Government Users Documentation related to restricted rights Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp.

3 Contents Instructor Exercises Overview v Exercises Description vii Table Descriptions xv Table Content xvii Exercises Exercise 1. Simple SQL Queries Exercise 2. Retrieving Data from Multiple Tables Exercise 3. Scalar Functions and Arithmetic Exercise 4. Column Functions and Grouping Exercise 5. UNION Exercise 6. Using Subqueries Exercise 7. Maintaining Data Copyright IBM Corp. 1999, 2000 Contents iii

4 iv DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

5 Instructor Exercises Overview Students are not required to do all of the problems in an exercise. They should complete as many problems as they can within the time allotted. Copyright IBM Corp. 1999, 2000 Instructor Exercises Overview v

6 vi DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

7 Exercises Description Read the General Information section and the description of the lab tables before attempting the exercises. Feel free to consult with the instructor if you need a hint or encounter difficulties while you are formulating a query. Problem List Contains a listing of the problems for that exercise. You may complete the lab problems from this listing. Expected s repeats the problem and shows the results from the completed query. In most cases, the complete result is shown. In cases where the result set is too large, an ellipsis (...) is shown to indicate that there are additional rows in the result. The number of rows for the result set is shown so you may verify your results. Solutions contains the query that solves the problem. There are sometimes several possible solutions. Your solution may differ from the one shown. If you have any doubts about whether your solution is correct or if it is as good as the given solution from a performance point of view, please consult your instructor. General Information This lab guide provides the information necessary to complete the required and optional labs for the DB2 SQL Workshop course. In countries that provide several query tools for each environment, this lab guide may be supplemented by additional documentation describing the basics of each query tool. The exercises for this course may be done in OS/390 or in a Workstation environment. Depending on the class location, any of the following Workstation platforms may be available: OS/2, AIX, Windows 95 or Windows NT. Read the instructions for your operating system before attempting the exercises. All Workstation platforms use the same instructions. You may use any of the query tools installed on the operating system. Please note that the emphasis of this course is on teaching SQL, not on tool use. Therefore, only the basics of the tool use is covered. For additional information about these tools, ask the instructor for recommendations on manuals to read or courses to take for this purpose. Although saving your queries is not required, feel free to comment out or save your solutions. Copyright IBM Corp. 1999, 2000 Exercises Description vii

8 Full solutions are provided for every question but if you wish to save your own solutions to diskette or print them, ask your instructor when you begin the first exercise. Diskettes or printers may not be available in every class. viii DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

9 General Information for OS/390 Users There are a variety of query tools that can work with DB2 for OS/390, including SPUFI, QMF, and others. You may use any of the tools that are installed to do the labs. The following query tools are available for this course: The instructor will tell you how to logon to the OS/390 system and what specific user ID and password to use. In addition, you will probably be given a team number: this number will be used occasionally during the exercises so that you can distinguish your files or objects from those of other students. Your logon ID is. Your password is. Your team number is. The instructor will give you brief verbal or written instructions on how to use the query tool you choose. For more information about a tool, for example how to save a query, be sure to ask the instructor. For SPUFI, you will need a partitioned dataset in order to complete the exercises. This dataset already exists. The dataset name is. Each of the tables described in the Table Relationships section of this document already exists and will be accessed through views owned by your lab ID. Your lab ID is. Within your SQL it is not necessary to prefix the table names with its qualifier. When you create TESTEMP table during the exercise 7, you may need to add an IN clause to your CREATE TABLE statements that identifies where the table is being created. The IN clause you need to add is: IN DBCF12xx.TSxx (where the xx is your team number). You are not required to save your SQL but if you want to save it, you may put it in your partitioned dataset. Copyright IBM Corp. 1999, 2000 Exercises Description ix

10 General Information for Workstation Users There are a variety of query tools that can work with DB2 on the workstation platforms including Command Center, CLP, QMF for Windows, and others. You may use any of the installed tools to do the labs. The following query tools are available for this course: Students doing the exercises on workstation platforms do not need a team number. Each workstation student has a complete standalone environment and will not share any files or tables with other students. Each student will need to sign on with the following information: USERID is PASSWORD is The instructor will give you brief verbal or written instructions on how to use the tool you choose so that you know enough to get started. If you want to know more about a tool, for example how to save a query, be sure to ask the instructor. A database named sample has already been created for you. to connect in a single-user environment, enter the following at a command prompt: db2 connect to sample To connect in a client/server environment, enter the following at a command prompt, substituting the userid and password you were assigned: db2 connect to sample user userid using password Each of the tables described in the Table Relationships section of this document already exists and has the same qualifier. The qualifier is. When you refer to these tables in your SQL, you will need to prefix the table names with the qualifier identified above. For example, if you want to display the complete contents of the EMPLOYEE table, enter the following, substituting the qualifier you were given: SELECT * FROM qualifier.employee In cases where you are using your TESTEMP table you need to omit the qualifier or use your logon ID as qualifier. For example, if you are trying to read the TESTEMP table, you will need to write: x DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

11 SELECT * FROM TESTEMP or SELECT * FROM logon ID.TESTEMP If you choose to do the labs in CLP, you may create your SQL in the \CF12 directory. Copyright IBM Corp. 1999, 2000 Exercises Description xi

12 Figure 0-1. Table Relationships (CF12X010) Notes: This diagram illustrates the relationships between the tables used in the exercises for this course. The lines show the connection between the tables. xii DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

13 Copyright IBM Corp. 1999, 2000 Exercises Description xiii

14 xiv DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

15 Table Descriptions The tables are described in hierarchical order, as shown in the Table Relationships on the previous page. DEPARTMENT There is one row in the DEPARTMENT table for each department in the company. Column Name Meaning Data Type NULLS allowed DEPTNO Department Number CHAR(3) N DEPTNAME Department Name VARCHAR(36) N MGRNO Employee Number of the Responsible CHAR(6) Y Manager ADMRDEPT Department Number of the CHAR(3) N Department to which the Department reports LOCATION Location Number CHAR(5) Y EMPLOYEE There is one row in the EMPLOYEE table for each of the employees in the company. Column Name Meaning Data Type NULLS allowed EMPNO Employee Number CHAR(6) N FIRSTNME First Name VARCHAR(20) N MIDINIT Middle Initial CHAR(1) N LASTNAME Last Name VARCHAR(15) N WORKDEPT Department in which the Employee CHAR(3) Y Works PHONENO Phone Number CHAR(4) Y HIREDATE Date of Hire DATE Y JOB Job CHAR(8) Y EDLEVEL Number of Years of Formal Education SMALLINT Y SEX Sex (M male, F female) CHAR(1) Y BIRTHDATE Date of Birth DATE Y SALARY Yearly Salary DECIMAL(9, 2) Y BONUS Yearly Bonus DECIMAL(9, 2) Y COMM Yearly Commission DECIMAL(9, 2) Y Copyright IBM Corp. 1999, 2000 Table Descriptions xv

16 PROJECT There is one row in the PROJECT table for each project. Column Name Meaning Data Type NULLS allowed PROJNO Project Number CHAR(6) N PROJNAME Project Name VARCHAR(24) N DEPTNO Responsible Department CHAR(3) N RESPEMP Employee Number of the Responsible CHAR(6) N Employee PRSTAFF Estimated Mean Staffing DECIMAL(5, 2) Y PRSTDATE Estimated Start Date DATE Y PRENDATE Estimated End Date DATE Y MAJPROJ Major Project for a Subproject CHAR(6) Y EMP_ACT There are many rows in the EMP_ACT table for any employee or any project. Column Name Meaning Data Type NULLS allowed EMPNO Employee Number of Employee CHAR(6) N Performing the Activity PROJNO Project Number CHAR(6) N ACTNO Activity Number SMALLINT N EMPTIME Proportion of Employee's Time Spent DECIMAL(5, 2) Y on Project EMSTDATE Date Activity Starts DATE Y EMENDATE Date Activity Ends DATE Y xvi DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

17 Table Content DEPARTMENT table DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION A00 SPIFFY COMPUTER SERVICE DIV A00 B01 PLANNING A00 C01 INFORMATION CENTER A00 D01 DEVELOPMENT CENTER - A00 D11 MANUFACTURING SYSTEMS D01 D21 ADMINISTRATION SYSTEMS D01 E01 SUPPORT SERVICES A00 E11 OPERATIONS E01 E21 SOFTWARE SUPPORT E01 Copyright IBM Corp. 1999, 2000 Table Content xvii

18 EMPLOYEE table EMPNO FIRSTNME MIDINIT LASTNAME WORKDEPT PHONENO HIREDATE CHRISTINE I HAAS A MICHAEL L THOMPSON B SALLY A KWAN C JOHN B GEYER E IRVING F STERN D EVA D PULASKI D EILEEN W HENDERSON E THEODORE Q SPENSER E VINCENZO G LUCCHESI A SEAN O'CONNELL A DOLORES M QUINTANA C HEATHER A NICHOLLS C BRUCE ADAMSON D ELIZABETH R PIANKA D MASATOSHI J YOSHIMURA D MARILYN S SCOUTTEN D JAMES H WALKER D DAVID BROWN D WILLIAM T JONES D JENNIFER K LUTZ D JAMES J JEFFERSON D SALVATORE M MARINO D DANIEL S SMITH D SYBIL V JOHNSON D MARIA L PEREZ D ETHEL R SCHNEIDER E JOHN R PARKER E PHILIP X SMITH E MAUDE F SETRIGHT E RAMLAL V MEHTA E WING LEE E JASON R GOUNOT E xviii DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

19 EMPLOYEE table (cont'd) JOB EDLEVEL SEX BIRTHDATE SALARY BONUS COMM PRES 18 F MANAGER 18 M MANAGER 20 F MANAGER 16 M MANAGER 16 M MANAGER 16 F MANAGER 16 F MANAGER 14 M SALESREP 19 M CLERK 14 M ANALYST 16 F ANALYST 18 F DESIGNER 16 M DESIGNER 17 F DESIGNER 16 M DESIGNER 17 F DESIGNER 16 M DESIGNER 16 M DESIGNER 17 M DESIGNER 18 F CLERK 14 M CLERK 17 M CLERK 15 M CLERK 16 F CLERK 15 F OPERATOR 17 F OPERATOR 12 M OPERATOR 14 M OPERATOR 12 F FIELDREP 16 M FIELDREP 14 M FIELDREP 16 M Copyright IBM Corp. 1999, 2000 Table Content xix

20 PROJECT table DEPT PR PROJNO PROJNAME NO RESPEMP STAFF PRSTDATE PRENDATE MAJPROJ AD3100 ADMIN SERVICES D AD3110 GENERAL AD SYSTEMS D AD3100 AD3111 PAYROLL PROGRAMMING D AD3110 AD3112 PERSONNEL PROGRAMMG D AD3110 AD3113 ACCOUNT.PROGRAMMING D AD3110 IF1000 QUERY SERVICES C IF2000 USER EDUCATION C MA2100 WELD LINE AUTOMATION D MA2110 W L PROGRAMMING D MA2100 MA2111 W L PROGRAM DESIGN D MA2110 MA2112 W L ROBOT DESIGN D MA2110 MA2113 W L PROD CONT PROGS D MA2110 OP1000 OPERATION SUPPORT E OP1010 OPERATION E OP1000 OP2000 GEN SYSTEMS SERVICES E OP2010 SYSTEMS SUPPORT E OP2000 OP2011 SCP SYSTEMS SUPPORT E OP2010 OP2012 APPLICATIONS SUPPORT E OP2010 OP2013 DB/DC SUPPORT E OP2010 PL2100 WELD LINE PLANNING B MA2100 xx DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

21 EMP_ACT table EMPNO PROJNO ACTNO EMPTIME EMSTDATE EMENDATE AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD IF IF IF IF Copyright IBM Corp. 1999, 2000 Table Content xxi

22 EMP_ACT table (cont'd) EMPNO PROJNO ACTNO EMPTIME EMSTDATE EMENDATE IF IF IF IF IF MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA OP OP OP OP OP OP OP OP OP OP OP OP OP OP PL xxii DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

23 Each exercise in this course is divided into sections as described below. Select the section that best fits your method of performing labs. You may elect to use a combination of these sections as appropriate. Problem List This section contains what it is you are to accomplish. There are no definitive details on how to perform the tasks. You are given the opportunity to work through the exercise given what you learned in the unit presentation, utilizing the unit Student Notebook, your past experience and maybe a little intuition. Problem List With Expected s This section is an exact duplicate of the Problem List section except that it includes the expected result of the query you are to write. Feel free to use the Problem List or the Problem List with Expected s when doing your lab problems. Solutions Follow the Problem List With Expected s. Copyright IBM Corp. 1999, 2000 Table Content xxiii

24 xxiv DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

25 Exercise 1. Simple SQL Queries What This Exercise is About This exercise provides an opportunity to write and execute basic SQL statements. What You Should Be Able to Do Introduction At the end of the lab, you should be able to: Code SELECT statements using four clauses of an SQL SELECT statement. Use a SELECT statement to: Retrieve all rows of a table Retrieve specific columns Retrieve rows based on comparisons to numeric or alphanumeric data Retrieve rows based on specific columns containing NULL values Code SELECT statements using keywords BETWEEN, IN, LIKE and DISTINCT Produce a result table whose rows are sorted in a desired sequence See the data model at the start of this exercise guide to get the column names and descriptions for each table. Required Materials Student handout SQL Reference Instructor Exercise Overview The students are not required to finish all problems. The student's experience and skill level will affect the number of problems they can complete. Hopefully there are more problems than can be completed within the time allotted so the experienced students will be as challenged as the novice. Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-1

26 Problem List Problem 1 Problem 2 List employee number, last name, date of birth, and salary for all employees who make more than $30,000 a year. Sequence the results in descending order by salary. List last name, first name, and the department number for all employees. The listing should be ordered by descending department numbers. Within the same department, the last names should be sorted in descending order. Problem 3 Problem 4 Problem 5 Problem 6 Problem 7 Problem 8 Problem 9 List the different education levels in the company in descending order. List only one occurrence of duplicate result rows. List employees, by employee number, and their assigned projects, by project number. Display only those employees with an employee number less than or equal to 100. List only one occurrence of duplicate rows. Sort the result rows by employee number. (Use the EMP_ACT table.) List last name, salary, and bonus of all male employees. List last name, salary, and commission for all employees with a salary greater than $20,000 and hired after List last name, salary, bonus, and commission for all employees with a salary greater than $22,000 and a bonus of $400, or for all employees with a bonus of $500 and a commission lower than $1,900. The list should be ordered by last name. List last name, salary, bonus, and commission for all employees with a salary greater than $22,000, a bonus of $400 or $500, and a commission less than $1,900. The list should be ordered by last name. Using the EMP_ACT table, for all projects that have a project number beginning with AD and have activities 10, 80, and 180 associated with them, list the following: Project number Activity number Starting date for activity Ending date for activity Order the list by activity number within project number. 1-2 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

27 Problem 10 Problem 11 Problem 12 Problem 13 Problem 14 Problem 15 List manager number and department number for all departments to which a manager has been assigned. The list should be ordered by manager number. List employee number, last name, salary, and bonus for all employees that have a bonus ranging from $800 to $1,000. Sort the report by employee number within bonus, lowest bonus first. List employee number, last name, salary, and department number for all employees in departments A00 through C01 (inclusive). Order the results alphabetically by last name and employee number. List all projects that have SUPPORT as part of the project name. Order the results by project number. List all departments that have a 1 as the middle character in the department number. Order the results by department number. List the last name, first name, middle initial, and salary of the five highest paid non-manager, non-president employees. Order the results by highest salary first. END OF LAB Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-3

28 Problem List With Expected s Problem 1 Problem 2 List employee number, last name, date of birth, and salary for all employees who make more than $30,000 a year. Sequence the results in descending order by salary. EMPNO LASTNAME BIRTHDATE SALARY HAAS LUCCHESI THOMPSON GEYER KWAN PULASKI STERN List last name, first name, and the department number for all employees. The listing should be ordered by descending department numbers. Within the same department, the last names should be sorted in descending order. LASTNAME FIRSTNME WORKDEPT SPENSER THEODORE E21 MEHTA RAMLAL E21 LEE WING E21 GOUNOT JASON E21 SMITH PHILIP E11 SETRIGHT MAUDE E11 SCHNEIDER ETHEL E11 PARKER JOHN E11 HENDERSON EILEEN E11 GEYER JOHN E The complete result set contains 32 rows. 1-4 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

29 Problem 3 Problem 4 List the different education levels in the company in descending order. List only one occurrence of duplicate result rows. EDLEVEL List employees, by employee number, and their assigned projects, by project number. Display only those employees with an employee number less than or equal to 100. List only one occurrence of duplicate rows. Sort the result rows by employee number. (Use the EMP_ACT table.) EMPNO PROJNO AD MA MA PL IF IF OP OP AD OP OP2010 Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-5

30 Problem 5 Problem 6 List last name, salary, and bonus of all male employees. LASTNAME SALARY BONUS THOMPSON GEYER STERN SPENSER LUCCHESI O'CONNELL ADAMSON YOSHIMURA WALKER BROWN JONES JEFFERSON MARINO SMITH PARKER SMITH MEHTA LEE GOUNOT List last name, salary, and commission for all employees with a salary greater than $20,000 and hired after LASTNAME SALARY COMM PULASKI SPENSER PEREZ DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

31 Problem 7 Problem 8 List last name, salary, bonus, and commission for all employees with a salary greater than $22,000 and a bonus of $400, or for all employees with a bonus of $500 and a commission lower than $1,900. The list should be ordered by last name. LASTNAME SALARY BONUS COMM JEFFERSON 22180,00 400, ,00 PIANKA 22250,00 400, ,00 SCOUTTEN 21340,00 500, ,00 List last name, salary, bonus, and commission for all employees with a salary greater than $22,000, a bonus of $400 or $500, and a commission less than $1,900. The list should be ordered by last name. LASTNAME SALARY BONUS COMM JEFFERSON PIANKA Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-7

32 Problem 9 Using the EMP_ACT table, for all projects that have a project number beginning with AD and have activities 10, 80, and 180 associated with them, list the following: Project number Activity number Starting date for activity Ending date for activity Order the list by activity number within project number. PROJNO ACTNO EMSTDATE EMENDATE AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

33 Problem 10 Problem 11 List manager number and department number for all departments to which a manager has been assigned. The list should be ordered by manager number. MGRNO DEPTNO A B C E D D E E21 List employee number, last name, salary, and bonus for all employees that have a bonus ranging from $800 to $1,000. Sort the report by employee number within bonus, lowest bonus first. EMPNO LASTNAME SALARY BONUS THOMPSON KWAN GEYER LUCCHESSI HAAS Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-9

34 Problem 12 Problem 13 Problem 14 List employee number, last name, salary, and department number for all employees in departments A00 through C01 (inclusive). Order the results alphabetically by last name and employee number. EMPNO LASTNAME SALARY WORKDEPT HAAS A KWAN C LUCCHESI A NICHOLLS C O'CONNELL A QUINTANA C THOMPSON B01 List all projects that have SUPPORT as part of the project name. Order the results by project number. PROJNO PROJNAME OP1000 OPERATION SUPPORT OP2010 SYSTEMS SUPPORT OP2011 SCP SYSTEMS SUPPORT OP2012 APPLICATIONS SUPPORT OP2013 DB/DC SUPPORT List all departments that have a 1 as the middle character in the department number. Order the results by department number. DEPTNO DEPTNAME D11 MANUFACTURING SYSTEMS E11 OPERATIONS 1-10 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

35 Problem 15 List the last name, first name, middle initial, and salary of the five highest paid non-manager, non-president employees. Order the results by highest salary first. LASTNAME FIRSTNME MIDINIT SALARY LUCCHESSI VINCENZO G LUTZ JENNIFER K O'CONNELL SEAN MARINO SALVATORE M NICHOLLS HEATHER A END OF Problem List With Expected s Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-11

36 Solution Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem 7 SELECT EMPNO, LASTNAME, BIRTHDATE, SALARY FROM EMPLOYEE WHERE SALARY > ORDER BY SALARY DESC SELECT LASTNAME, FIRSTNME, WORKDEPT FROM EMPLOYEE ORDER BY WORKDEPT DESC, LASTNAME DESC SELECT DISTINCT EDLEVEL FROM EMPLOYEE ORDER BY EDLEVEL DESC SELECT DISTINCT EMPNO, PROJNO FROM EMP_ACT WHERE EMPNO <= '000100' ORDER BY EMPNO SELECT LASTNAME, SALARY, BONUS FROM EMPLOYEE WHERE SEX = 'M' SELECT LASTNAME, SALARY, COMM FROM EMPLOYEE WHERE HIREDATE >= ' ' AND SALARY > SELECT LASTNAME, SALARY, BONUS, COMM FROM EMPLOYEE WHERE SALARY > AND BONUS = 400 OR BONUS = 500 AND COMM < 1900 ORDER BY LASTNAME 1-12 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

37 Problem 8 Problem 9 Problem 10 Problem 11 Problem 12 Problem 13 Problem 14 SELECT LASTNAME, SALARY, BONUS, COMM FROM EMPLOYEE WHERE SALARY > AND ( BONUS = 400 OR BONUS = 500 ) AND COMM < 1900 ORDER BY LASTNAME SELECT PROJNO, ACTNO, EMSTDATE, EMENDATE FROM EMP_ACT WHERE ACTNO IN (10, 80, 180) AND PROJNO LIKE 'AD%' ORDER BY PROJNO, ACTNO SELECT MGRNO, DEPTNO FROM DEPARTMENT WHERE MGRNO IS NOT NULL ORDER BY MGRNO SELECT EMPNO, LASTNAME, SALARY, BONUS FROM EMPLOYEE WHERE BONUS BETWEEN 800 AND 1000 ORDER BY BONUS, EMPNO SELECT EMPNO, LASTNAME, SALARY, WORKDEPT FROM EMPLOYEE WHERE WORKDEPT BETWEEN 'A00' AND 'C01' ORDER BY LASTNAME, EMPNO SELECT PROJNO, PROJNAME FROM PROJECT WHERE PROJNAME LIKE '%SUPPORT%' ORDER BY PROJNO SELECT DEPTNO, DEPTNAME FROM DEPARTMENT WHERE DEPTNO LIKE '_1_' ORDER BY DEPTNO Copyright IBM Corp. 1999, 2000 Exercise 1. Simple SQL Queries 1-13

38 Problem 15 SELECT LASTNAME, FIRSTNME, MIDINIT, SALARY FROM EMPLOYEE WHERE JOB NOT IN ('PRES', 'MANAGER') ORDER BY SALARY DESC FETCH FIRST 5 ROWS ONLY END OF SOLUTION 1-14 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

39 Exercise 2. Retrieving Data from Multiple Tables What This Exercise is About This exercise provides an opportunity to write queries that retrieve data from more than one table. What You Should Be Able to Do At the end of the lab, you should be able to: Code SELECT statements referencing multiple tables or views. Introduction See the data model at the start of this exercise guide to get the column names and descriptions for each table. Required Materials Student handout SQL Reference Instructor Exercise Overview Remind the students to complete as many of the problems as they can within the allotted time. It is not necessary that they complete all of the problems. Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-1

40 Problem List Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Produce a report that lists employees' last names, first names, and department names. Sequence the report on first name within last name, within department name. Modify the previous query to include job. Also, list data for only departments between A02 and D22, and exclude managers from the list. Sequence the report on first name within last name, within job, within department name. List the name of each department and the lastname and first name of its manager. Sequence the list by department name. Use the EMPNO and MGRNO columns to relate the two tables. Sequence the result rows by department name. Try the following: modify the previous query using WORKDEPT and DEPTNO as the join predicate. Include a local predicate that looks for people whose job is manager. Are the results from both queries the same? Why? For all projects that have a project number beginning with AD, list project number, project name, and activity number. List identical rows once. Order the list by project number and then by activity number. Which employees are assigned to project number AD3113? List employee number, last name, and project number. Order the list by employee number and then by project number. List only one occurrence of duplicate result rows. 2-2 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

41 Problem 7 Problem 8 Problem 9 Problem 10 Problem 11 Which activities began on October 1, 1982? For each of these activities, list the employee number of the person performing the activity, the project number,project name, activity number, and starting date of the activity. Order the list by project number, then by employee number, and then by activity number. Display department number, last name, project name, and activity number for activities performed by the employees in department A00. Sequence the results first by project name and then by activity number. List department number, last name, project name, and activity number for those employees in work departments A00 through C01. Suppress identical rows. Sort the list by department number, last name, and activity number. The second line manager needs a list of activities which began on October 15, 1982 or thereafter. For these activities, list the activity number, the manager number of the manager of the department assigned to the project, the starting date for the activity, the project number, and the last name of the employee performing the activity. The list should be ordered by the activity number and then by the activity start date. Which employees in department A00 were hired before their manager? List department number, the manager's last name, the employee's last name, and the hiring dates of both the manager and the employee. Order the list by the employee's last name. END OF LAB Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-3

42 Problem List With Expected s Problem 1 RESULT Produce a report that lists employees' last names, first names, and department names. Sequence the report on first name within last name, within department name. LASTNAME FIRSTNME DEPTNAME JEFFERSON JAMES ADMINISTRATION SYSTEMS JOHNSON SYBIL ADMINISTRATION SYSTEMS MARINO SALVATORE ADMINISTRATION SYSTEMS PEREZ MARIA ADMINISTRATION SYSTEMS PULASKI EVA ADMINISTRATION SYSTEMS SMITH DANIEL ADMINISTRATION SYSTEMS KWAN SALLY INFORMATION CENTER NICHOLLS HEATHER INFORMATION CENTER QUINTANA DOLORES INFORMATION CENTER ADAMSON BRUCE MANUFACTURING SYSTEMS BROWN DAVID MANUFACTURING SYSTEMS JONES WILLIAM MANUFACTURING SYSTEMS LUTZ JENNIFER MANUFACTURING SYSTEMS PIANKA ELIZABETH MANUFACTURING SYSTEMS SCOUTTEN MARILYN MANUFACTURING SYSTEMS STERN IRVING MANUFACTURING SYSTEMS WALKER JAMES MANUFACTURING SYSTEMS YOSHIMURA MASATOSHI MANUFACTURING SYSTEMS HENDERSON EILEEN OPERATIONS PARKER JOHN OPERATIONS SCHNEIDER ETHEL OPERATIONS SETRIGHT MAUDE OPERATIONS SMITH PHILIP OPERATIONS THOMPSON MICHAEL PLANNING GOUNOT JASON SOFTWARE SUPPORT LEE WING SOFTWARE SUPPORT MEHTA RAMLAL SOFTWARE SUPPORT SPENSER THEODORE SOFTWARE SUPPORT HAAS CHRISTINE SPIFFY COMPUTER SERVICE DIV. LUCCHESSI VINCENZO SPIFFY COMPUTER SERVICE DIV. O'CONNELL SEAN SPIFFY COMPUTER SERVICE DIV. GEYER JOHN SUPPORT SERVICES 2-4 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

43 Problem 2 RESULT Modify the previous query to include job. Also, list data for only departments between A02 and D22, and exclude managers from the list. Sequence the report on first name within last name, within job, within department name. LASTNAME FIRSTNME DEPTNAME JOB JEFFERSON JAMES ADMINISTRATION SYSTEMS CLERK JOHNSON SYBIL ADMINISTRATION SYSTEMS CLERK MARINO SALVATORE ADMINISTRATION SYSTEMS CLERK PEREZ MARIA ADMINISTRATION SYSTEMS CLERK SMITH DANIEL ADMINISTRATION SYSTEMS CLERK NICHOLLS HEATHER INFORMATION CENTER ANALYST QUINTANA DOLORES INFORMATION CENTER ANALYST ADAMSON BRUCE MANUFACTURING SYSTEMS DESIGNER BROWN DAVID MANUFACTURING SYSTEMS DESIGNER JONES WILLIAM MANUFACTURING SYSTEMS DESIGNER LUTZ JENNIFER MANUFACTURING SYSTEMS DESIGNER PIANKA ELIZABETH MANUFACTURING SYSTEMS DESIGNER SCOUTTEN MARILYN MANUFACTURING SYSTEMS DESIGNER WALKER JAMES MANUFACTURING SYSTEMS DESIGNER YOSHIMURA MASATOSHI MANUFACTURING SYSTEMS DESIGNER Problem 3 RESULT List the name of each department and the lastname and first name of its manager. Sequence the list by department name. Use the EMPNO and MGRNO columns to relate the two tables. Sequence the result rows by department name. DEPTNAME LASTNAME FIRSTNME ADMINISTRATION SYSTEMS PULASKI EVA INFORMATION CENTER KWAN SALLY MANUFACTURING SYSTEMS STERN IRVING OPERATIONS HENDERSON EILEEN PLANNING THOMPSON MICHAEL SOFTWARE SUPPORT SPENSER THEODORE SPIFFY COMPUTER SERVICE DIV. HAAS CHRISTINE SUPPORT SERVICES GEYER JOHN Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-5

44 Problem 4 RESULT Problem 5 Try the following: modify the previous query using WORKDEPT and DEPTNO as the join predicate. Include a local predicate that looks for people whose job is manager. Are the results from both queries the same? Why? DEPTNAME LASTNAME FIRSTNME ADMINISTRATION SYSTEMS PULASKI EVA INFORMATION CENTER KWAN SALLY MANUFACTURING SYSTEMS STERN IRVING OPERATIONS HENDERSON EILEEN PLANNING THOMPSON MICHAEL SOFTWARE SUPPORT SPENSER THEODORE SUPPORT SERVICES GEYER JOHN For all projects that have a project number beginning with AD, list project number, project name, and activity number. List identical rows once. Order the list by project number and then by activity number. PROJNO PROJNAME ACTNO AD3100 ADMIN SERVICES 10 AD3110 GENERAL AD SYSTEMS 10 AD3111 PAYROLL PROGRAMMING 60 AD3111 PAYROLL PROGRAMMING 70 AD3111 PAYROLL PROGRAMMING 80 AD3111 PAYROLL PROGRAMMING 180 AD3112 PERSONNEL PROGRAMMG 60 AD3112 PERSONNEL PROGRAMMG 70 AD3112 PERSONNEL PROGRAMMG 80 AD3112 PERSONNEL PROGRAMMG 180 AD3113 ACCOUNT.PROGRAMMING 60 AD3113 ACCOUNT.PROGRAMMING 70 AD3113 ACCOUNT.PROGRAMMING 80 AD3113 ACCOUNT.PROGRAMMING DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

45 Problem 6 Problem 7 Which employees are assigned to project number AD3113? List employee number, last name, and project number. Order the list by employee number and then by project number. List only one occurrence of duplicate result rows. EMPNO LASTNAME PROJNO JOHNSON AD PEREZ AD3113 Which activities began on October 1, 1982? For each of these activities, list the employee number of the person performing the activity, the project number,project name, activity number, and starting date of the activity. Order the list by project number, then by employee number, and then by activity number. EMPNO PROJNO PROJNAME ACTNO EMSTDATE IF1000 QUERY SERVICES IF1000 QUERY SERVICES IF2000 USER EDUCATION MA2112 W L ROBOT DESIGN MA2113 W L PROD CONT PROGS MA2113 W L PROD CONT PROGS Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-7

46 Problem 8 Problem 9 Display department number, last name, project name, and activity number for activities performed by the employees in department A00. Sequence the results first by project name and then by activity number. WORKDEPT LASTNAME PROJNAME ACTNO A00 HAAS ADMIN SERVICES 10 A00 HAAS W L PROGRAMMING 10 A00 HAAS WELD LINE AUTOMATION 10 A00 LUCCHESI WELD LINE AUTOMATION 20 List department number, last name, project name, and activity number for those employees in work departments A00 through C01. Suppress identical rows. Sort the list by department number, last name, and activity number. WORKDEPT LASTNAME PROJNAME ACTNO A00 HAAS ADMIN SERVICES 10 A00 HAAS W L PROGRAMMING 10 A00 HAAS WELD LINE AUTOMATION 10 A00 LUCCHESI WELD LINE AUTOMATION 20 B01 THOMPSON WELD LINE PLANNING 30 C01 KWAN QUERY SERVICES 10 C01 KWAN USER EDUCATION 10 C01 NICHOLLS QUERY SERVICES 90 C01 NICHOLLS USER EDUCATION 100 C01 NICHOLLS USER EDUCATION 110 C01 QUINTANA QUERY SERVICES 90 C01 QUINTANA QUERY SERVICES DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

47 Problem 10 Problem 11 The second line manager needs a list of activities which began on October 15, 1982 or thereafter. For these activities, list the activity number, the manager number of the manager of the department assigned to the project, the starting date for the activity, the project number, and the last name of the employee performing the activity. The list should be ordered by the activity number and then by the activity start date. ACTNO MGRNO EMSTDATE PROJNO LASTNAME AD3112 SMITH AD3112 SMITH AD3113 PEREZ AD3112 SMITH AD3111 JEFFERSON Which employees in department A00 were hired before their manager? List department number, the manager's last name, the employee's last name, and the hiring dates of both the manager and the employee. Order the list by the employee's last name. DEPTNO MANAGER EMPLOYEE M_HIREDATE E_HIREDATE A00 HAAS LUCCHESI A00 HAAS O'CONNELL END OF Problem List With Expected s Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-9

48 Solution Problem 1 SELECT E.LASTNAME, E.FIRSTNME, D.DEPTNAME FROM EMPLOYEE E, DEPARTMENT D WHERE E.WORKDEPT = D.DEPTNO ORDER BY D.DEPTNAME, E.LASTNAME, E.FIRSTNME OR Problem 2 SELECT E.LASTNAME, E.FIRSTNME, D.DEPTNAME FROM EMPLOYEE E JOIN DEPARTMENT D ON E.WORKDEPT = D.DEPTNO ORDER BY D.DEPTNAME, E.LASTNAME, E.FIRSTNME SELECT E.LASTNAME, E.FIRSTNME, D.DEPTNAME, E.JOB FROM EMPLOYEE E, DEPARTMENT D WHERE E.WORKDEPT = D.DEPTNO AND E.WORKDEPT BETWEEN 'A02' AND 'D22' AND JOB <> 'MANAGER' ORDER BY D.DEPTNAME, E.LASTNAME, E.FIRSTNME OR SELECT E.LASTNAME, E.FIRSTNME, D.DEPTNAME, E.JOB FROM EMPLOYEE E JOIN DEPARTMENT D ON E.WORKDEPT = D.DEPTNO WHERE E.WORKDEPT BETWEEN 'A02' AND 'D22' AND JOB <> 'MANAGER' ORDER BY D.DEPTNAME, E.LASTNAME, E.FIRSTNME 2-10 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

49 Problem 3 SELECT D.DEPTNAME, E.LASTNAME, E.FIRSTNME FROM DEPARTMENT D, EMPLOYEE E WHERE D.MGRNO = E.EMPNO ORDER BY D.DEPTNAME OR SELECT D.DEPTNAME, E.LASTNAME, E.FIRSTNME FROM DEPARTMENT D JOIN EMPLOYEE E ON D.MGRNO = E.EMPNO ORDER BY D.DEPTNAME Problem 4 SELECT D.DEPTNAME, E.LASTNAME, E.FIRSTNME FROM DEPARTMENT D, EMPLOYEE E WHERE D.DEPTNO = E.WORKDEPT AND JOB = 'MANAGER' ORDER BY D.DEPTNAME OR SELECT D.DEPTNAME, E.LASTNAME, E.FIRSTNME FROM DEPARTMENT D JOIN EMPLOYEE E ON D.DEPTNO = E.WORKDEPT WHERE JOB = 'MANAGER' ORDER BY D.DEPTNAME The results of the queries in problem 3 and 4 are not the same. The department named Spiffy Computer Services Div. is not in the second report. reason: the job title of that department's manager is PRES. Our WHERE clause only allows qualified persons with a job of MANAGER to be joined with their department rows. It is very important to learn the data within your tables! The Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-11

50 Problem 5 SELECT DISTINCT A.PROJNO, PROJNAME, ACTNO FROM PROJECT P, EMP_ACT A WHERE P.PROJNO = A.PROJNO AND A.PROJNO LIKE 'AD%' ORDER BY A.PROJNO, ACTNO or Problem 6 SELECT DISTINCT A.PROJNO, PROJNAME, ACTNO FROM PROJECT AS P JOIN EMP_ACT AS A ON P.PROJNO = A.PROJNO WHERE A.PROJNO LIKE 'AD%' ORDER BY A.PROJNO, ACTNO SELECT DISTINCT A.EMPNO, LASTNAME, PROJNO FROM EMPLOYEE E, EMP_ACT A WHERE A.EMPNO = E.EMPNO AND A.PROJNO = 'AD3113' ORDER BY A.EMPNO, PROJNO or SELECT DISTINCT A.EMPNO,LASTNAME, PROJNO FROM EMPLOYEE AS E JOIN EMP_ACT AS A ON E.EMPNO = A.EMPNO WHERE A.PROJNO = 'AD3113' ORDER BY A.EMPNO, PROJNO 2-12 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

51 Problem 7 SELECT A.EMPNO, A.PROJNO, PROJNAME, ACTNO, EMSTDATE FROM PROJECT P, EMP_ACT A WHERE A.PROJNO = P.PROJNO AND EMSTDATE = ' ' ORDER BY A.PROJNO, A.EMPNO, ACTNO or Problem 8 SELECT A.EMPNO, A.PROJNO, PROJNAME, ACTNO, EMSTDATE FROM PROJECT AS P JOIN EMP_ACT AS A ON P.PROJNO = A.PROJNO WHERE A.EMSTDATE = ' ' ORDER BY A.PROJNO, A.EMPNO, ACTNO SELECT E.WORKDEPT, E.LASTNAME, P.PROJNAME, A.ACTNO FROM EMPLOYEE E, PROJECT P, EMP_ACT A WHERE E.EMPNO = A.EMPNO AND A.PROJNO = P.PROJNO AND E.WORKDEPT = 'A00' ORDER BY P.PROJNAME, A.ACTNO OR SELECT E.WORKDEPT, E.LASTNAME, P.PROJNAME, A.ACTNO FROM EMPLOYEE AS E JOIN EMP_ACT AS A ON E.EMPNO = A.EMPNO JOIN PROJECT AS P ON A.PROJNO = P.PROJNO WHERE E.WORKDEPT = 'A00' ORDER BY P.PROJNAME, A.ACTNO Copyright IBM Corp. 1999, 2000 Exercise 2. Multiple Tables 2-13

52 Problem 9 SELECT DISTINCT E.WORKDEPT, E.LASTNAME, P.PROJNAME, A.ACTNO FROM EMPLOYEE E, PROJECT P, EMP_ACT A WHERE E.EMPNO = A.EMPNO AND A.PROJNO = P.PROJNO AND E.WORKDEPT BETWEEN 'A00' AND 'C01' ORDER BY E.WORKDEPT, E.LASTNAME, A.ACTNO OR Problem 10 SELECT DISTINCT E.WORKDEPT, E.LASTNAME, P.PROJNAME, A.ACTNO FROM EMPLOYEE E JOIN EMP_ACT A ON E.EMPNO = A.EMPNO JOIN PROJECT P ON A.PROJNO = P.PROJNO WHERE E.WORKDEPT BETWEEN 'A00' AND 'C01' ORDER BY E.WORKDEPT, E.LASTNAME, A.ACTNO SELECT A.ACTNO, D.MGRNO, A.EMSTDATE, P.PROJNO, E.LASTNAME FROM DEPARTMENT D, EMPLOYEE E, PROJECT P, EMP_ACT A WHERE E.EMPNO = A.EMPNO AND A.PROJNO = P.PROJNO AND E.WORKDEPT = D.DEPTNO AND A.EMSTDATE >= ' ' ORDER BY A.ACTNO, A.EMSTDATE OR SELECT A.ACTNO, D.MGRNO, A.EMSTDATE, E.LASTNAME FROM EMPLOYEE AS E JOIN EMP_ACT AS A ON E.EMPNO = A.EMPNO JOIN PROJECT AS P ON A.PROJNO = P.PROJNO JOIN DEPARTMENT AS D ON E.WORKDEPT = D.DEPTNO WHERE A.EMSTDATE >= ' ' ORDER BY A.ACTNO, A.EMSTDATE 2-14 DB2 SQL Workshop Copyright IBM Corp. 1999, 2000

DB2 SQL Workshop for Experienced Users (Course Code CF13)

DB2 SQL Workshop for Experienced Users (Course Code CF13) DB2 SQL Workshop for Experienced Users (Course Code CF13) ERC4.1 IBM Learning Services Worldwide Certified Material Publishing Information This publication has been produced using BookMaster (Program Number

More information

DB2 SQL for the 21 st Century: Overlooked Enhancements. David Simpson

DB2 SQL for the 21 st Century: Overlooked Enhancements. David Simpson DB2 SQL for the 21 st Century: Overlooked Enhancements David Simpson dsimpson@themisinc.com Themis Education Most complete DB2 Curriculum in the industry Offerings include a complete mainframe curriculum

More information

After completing this unit, you should be able to: Define the terms

After completing this unit, you should be able to: Define the terms Introduction Copyright IBM Corporation 2007 Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3 3.3.1 Unit Objectives After completing this unit,

More information

You can access VSAM and sequential datasets in batch mode, and you can retrieve, view, and update VSAM and temporary storage queues in online mode.

You can access VSAM and sequential datasets in batch mode, and you can retrieve, view, and update VSAM and temporary storage queues in online mode. DATAMINER Comprehensive Information and Data-Management System CA-EASYTRIEVE TO DATAMINER: COMPARE, CONVERT, REPLACE DATAMINER FOR Z/OS AND Z/VSE DATAMINER is a collection of powerful data-mining and datamanipulation

More information

After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table

After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table JOIN Objectives After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table Use outer joins complementing inner joins Sample Tables for Unit EMPLOYEE EMPNO

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Alexandra Roatiş David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2016 CS 348 SQL Winter

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2017 CS 348 (Intro to DB Mgmt) SQL

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt) SQL

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

Advanced SQL and the Power of Rewriting Queries

Advanced SQL and the Power of Rewriting Queries Advanced SQL and the Power of Rewriting Queries Tony Andrews Themis Inc. Session Code: E07 Tuesday May24, 10:30 Platform: Application Developer Track Photo by Steve from Austin, TX, USA Often times there

More information

Maintaining Data 3.3.1

Maintaining Data 3.3.1 Maintaining Data Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3 3.3.1 Unit Objectives After completing this unit, you should be able to: Create

More information

DB2 Advanced SQL Working with Complex Queries. Tony Andrews, Application Tuning Consultant Themis, Inc.

DB2 Advanced SQL Working with Complex Queries. Tony Andrews, Application Tuning Consultant Themis, Inc. DB2 Advanced SQL Working with Complex Queries Tony Andrews, Application Tuning Consultant Themis, Inc. tandrews@themisinc.com www.themisinc.com DB2 Advanced SQL Working with Complex Queries Themis and

More information

Query Optimization Overview

Query Optimization Overview Query Optimization Overview parsing, syntax checking semantic checking check existence of referenced relations and attributes disambiguation of overloaded operators check user authorization query rewrites

More information

Notes. CS 640 Relational Algebra Winter / 16. Notes. CS 640 Relational Algebra Winter / 16. Notes

Notes. CS 640 Relational Algebra Winter / 16. Notes. CS 640 Relational Algebra Winter / 16. Notes Relational Algebra Tamer Özsu David R. Cheriton School of Computer Science University of Waterloo CS 640 Principles of Database Management and Use Winter 2013 CS 640 Relational Algebra Winter 2013 1 /

More information

The Relational Model

The Relational Model The Relational Model Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB Mgmt) Relational Model

More information

Cost Models. the query database statistics description of computational resources, e.g.

Cost Models. the query database statistics description of computational resources, e.g. Cost Models An optimizer estimates costs for plans so that it can choose the least expensive plan from a set of alternatives. Inputs to the cost model include: the query database statistics description

More information

Query Optimization Overview

Query Optimization Overview Query Optimization Overview parsing, syntax checking semantic checking check existence of referenced relations and attributes disambiguation of overloaded operators check user authorization query rewrites

More information

Unit 4. Scalar Functions and Arithmetic

Unit 4. Scalar Functions and Arithmetic Unit 4. Scalar Functions and Arithmetic What This Unit Is About Scalar functions can be used to manipulate column or expression values. This unit will discuss the format and syntax of basic scalar functions.

More information

Data Modelling and Multimedia Databases M

Data Modelling and Multimedia Databases M ALMA MATER STUDIORUM - UNIVERSITÀ DI BOLOGNA Data Modelling and Multimedia Databases M International Second cycle degree programme (LM) in Digital Humanities and Digital Knowledge (DHDK) University of

More information

Data Modelling and Multimedia Databases M

Data Modelling and Multimedia Databases M ALMA MATER STUDIORUM - UNIVERSITÀ DI BOLOGNA Data Modelling and Multimedia Databases M International Second cycle degree programme (LM) in Digital Humanities and Digital Knowledge (DHDK) University of

More information

V cover. Front cover. DB2 Stored Procedures Programming Workshop. (Course Code CF71) Student Exercises ERC 4.0. IBM Certified Course Material

V cover. Front cover. DB2 Stored Procedures Programming Workshop. (Course Code CF71) Student Exercises ERC 4.0. IBM Certified Course Material V2.0.0.1 cover Front cover DB2 Stored Procedures Programming Workshop (Course Code CF71) Student Exercises ERC 4.0 IBM Certified Course Material Student Exercises Trademarks IBM is a registered trademark

More information

Installing and Administering a Satellite Environment

Installing and Administering a Satellite Environment IBM DB2 Universal Database Installing and Administering a Satellite Environment Version 8 GC09-4823-00 IBM DB2 Universal Database Installing and Administering a Satellite Environment Version 8 GC09-4823-00

More information

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version :

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version : IBM A2090-730 Assessment: DB2 9 Fundamentals-Assessment Download Full Version : http://killexams.com/pass4sure/exam-detail/a2090-730 C. 2 D. 3 Answer: C QUESTION: 294 In which of the following situations

More information

IBM DB2 Universal Database. SQL Getting Started. Version 7 SC

IBM DB2 Universal Database. SQL Getting Started. Version 7 SC IBM DB2 Universal Database SQL Getting Started Version 7 SC09-2973-00 IBM DB2 Universal Database SQL Getting Started Version 7 SC09-2973-00 Before using this information and the product it supports, be

More information

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary Course Summary Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge

More information

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Charting the Course to Your Success! MOC D Querying Microsoft SQL Server Course Summary Course Summary Description This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server 2014. This course is the foundation

More information

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces

More information

Front cover. DB2 Universal Database Programming Workshop for Linux, UNIX, and Windows (Course Code CF10) Lab Set Up Guide

Front cover. DB2 Universal Database Programming Workshop for Linux, UNIX, and Windows (Course Code CF10) Lab Set Up Guide V3.0 cover Front cover DB2 Universal Database Programming Workshop for Linux, UNIX, and Windows (Course Code CF10) Lab Set Up Guide ERC 8.1 IBM Certified Course Material Lab Set Up Guide Trademarks IIBM

More information

IBM DB2 9 Family Fundamentals. Download Full Version :

IBM DB2 9 Family Fundamentals. Download Full Version : IBM 000-730 DB2 9 Family Fundamentals Download Full Version : http://killexams.com/pass4sure/exam-detail/000-730 Answer: D QUESTION: 292 The EMPLOYEE table contains the following information: EMPNO NAME

More information

Visual Explain Tutorial

Visual Explain Tutorial IBM DB2 Universal Database Visual Explain Tutorial Version 8 IBM DB2 Universal Database Visual Explain Tutorial Version 8 Before using this information and the product it supports, be sure to read the

More information

Unit 6. Scalar Functions

Unit 6. Scalar Functions Unit 6. Scalar Functions What This Unit Is About This unit provides information on how to use various common scalar functions. What You Should Be Able to Do After completing this unit, you should be able

More information

RESTRICTING AND SORTING DATA

RESTRICTING AND SORTING DATA RESTRICTING AND SORTING DATA http://www.tutorialspoint.com/sql_certificate/restricting_and_sorting_data.htm Copyright tutorialspoint.com The essential capabilities of SELECT statement are Selection, Projection

More information

Table : Purchase. Field DataType Size Constraints CustID CHAR 5 Primary key CustName Varchar 30 ItemName Varchar 30 PurchaseDate Date

Table : Purchase. Field DataType Size Constraints CustID CHAR 5 Primary key CustName Varchar 30 ItemName Varchar 30 PurchaseDate Date Q1. Write SQL query for the following : (i) To create above table as per specification given (ii) To insert 02 records as per your choice (iii) Display the Item name, qty & s of all items purchased by

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

Tables From Existing Tables

Tables From Existing Tables Creating Tables From Existing Tables After completing this module, you will be able to: Create a clone of an existing table. Create a new table from many tables using a SQL SELECT. Define your own table

More information

INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION

INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION Grade- XI COMPUTER SCIENCE Unit I Programming and Computational Thinking 1. What are the functions of computer? 2. Briefly explain the basic architecture

More information

,LOCATE_IN_STRING(lastName, 'SON', 1, 1) AS Location_of_String derrja.employee

,LOCATE_IN_STRING(lastName, 'SON', 1, 1) AS Location_of_String derrja.employee SELECT FROM WHERE lastname,locate_in_string(lastname, 'SON', 1, 1) AS Location_of_String derrja.employee lastname LIKE('%SON%'); -- Find the location of the word AMERICAN in the string, and extract that

More information

INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION. Subject- Informatics Practices

INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION. Subject- Informatics Practices Grade- XI INTERNATIONAL INDIAN SCHOOL, RIYADH XI XII BOYS SECTION Unit 1 Programming and Computational Thinking Chapter 1 Introduction to Computer Systems 1. What are the functions of computer? 2. What

More information

CA Chorus for DB2 Database Management

CA Chorus for DB2 Database Management CA Chorus for DB2 Database Management CA Performance Handbook for DB2 for z/os Version 04.0.00 This Documentation, which includes embedded help systems and electronically distributed materials (hereinafter

More information

Full file at

Full file at David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard

More information

GIFT Department of Computing Science. CS-217: Database Systems. Lab-4 Manual. Reporting Aggregated Data using Group Functions

GIFT Department of Computing Science. CS-217: Database Systems. Lab-4 Manual. Reporting Aggregated Data using Group Functions GIFT Department of Computing Science CS-217: Database Systems Lab-4 Manual Reporting Aggregated Data using Group Functions V3.0 4/28/2016 Introduction to Lab-4 This lab further addresses functions. It

More information

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36 Database Processing, 12e (Kroenke/Auer) Chapter 2: Introduction to Structured Query Language (SQL) 1) SQL stands for Standard Query Language. Diff: 1 Page Ref: 32 2) SQL includes a data definition language,

More information

A View to a Kill. Please reload this page to view the headlines. 1 of 21 5/20/2009 9:18 AM. by Craig Mullins. Discussion Points

A View to a Kill. Please reload this page to view the headlines. 1 of 21 5/20/2009 9:18 AM. by Craig Mullins. Discussion Points 1 of 21 5/20/2009 9:18 AM A View to a Kill by Craig Mullins Discussion Points Contents Is it practical and/or advisable to implement base table views to insulate application programs from database change?

More information

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez SQL Queries for Mere Mortals Third Edition A Hands-On Guide to Data Manipulation in SQL John L. Viescas Michael J. Hernandez r A TT TAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco

More information

Part III. Data Modelling. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1

Part III. Data Modelling. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1 Part III Data Modelling Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1 Outline of this part (I) 1 Introduction to the Relational Model and SQL Relational Tables Simple Constraints

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke

Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Link full download: https://testbankservice.com/download/test-bank-fordatabase-processing-fundamentals-design-and-implementation-13th-edition-bykroenke

More information

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO INSERT INTO DEPT VALUES(4, 'Prog','MO'); The result

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

Business Intelligence Tutorial

Business Intelligence Tutorial IBM DB2 Universal Database Business Intelligence Tutorial Version 7 IBM DB2 Universal Database Business Intelligence Tutorial Version 7 Before using this information and the product it supports, be sure

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

tdb2temporalmergeelt Purpose http://www.cimt-ag.de This component carries out the creation and fill procedure for Temporal Tables in the IBM DB2. Temporal Tables are introduced with DB2 v10 and provides

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

Using JDBC Data Source with DB2

Using JDBC Data Source with DB2 Using JDBC Data Source with DB2 Using JDBC Data Source with DB2 Elixir Repertoire provides DB2 connectivity with JDBC Data Source via DB2 Universal JDBC driver (Type 4). Prerequisites Below is a list of

More information

Vendor: IBM. Exam Code: Exam Name: DB Fundamentals. Version: DEMO

Vendor: IBM. Exam Code: Exam Name: DB Fundamentals. Version: DEMO Vendor: IBM Exam Code: 000-610 Exam Name: DB2 10.1 Fundamentals Version: DEMO QUESTION 1 What is the act of exchanging one lock an application holds on a resource for a more restrictive lock on the same

More information

Optimize Enterprise Generation Language (EGL) applications using purequery

Optimize Enterprise Generation Language (EGL) applications using purequery Optimize Enterprise Generation Language (EGL) applications using purequery Venkatesh Gopal, Data Studio Development Team Kathryn Zeidenstein, Data Studio Enablement team 1 About EGL and purequery... 3

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

DB2 9 DBA exam 731 prep, Part 3: Database access

DB2 9 DBA exam 731 prep, Part 3: Database access DB2 9 DBA exam 731 prep, Part 3: Database access Skill Level: Introductory George Baklarz (baklarz@yahoo.com) Manager, DB2 Worldwide Pre-sales Support Group IBM 18 Jul 2006 This tutorial will take you

More information

The SQL Guide to Pervasive PSQL. Rick F. van der Lans

The SQL Guide to Pervasive PSQL. Rick F. van der Lans The SQL Guide to Pervasive PSQL Rick F. van der Lans Copyright 2009 by R20/Consultancy All rights reserved; no part of this publication may be reproduced, stored in a retrieval system, or transmitted in

More information

DB2 9 DBA exam 731 prep, Part 3: Database access

DB2 9 DBA exam 731 prep, Part 3: Database access DB2 9 DBA exam 731 prep, Part 3: Database access Skill Level: Introductory George Baklarz (baklarz@yahoo.com) Manager, DB2 Worldwide Pre-sales Support Group IBM 18 Jul 2006 This tutorial will take you

More information

CITY UNIVERSITY OF NEW YORK. i. Visit:

CITY UNIVERSITY OF NEW YORK. i. Visit: CITY UNIVERSITY OF NEW YORK I. ACCESSING IRB NET (New Registration) i. Visit: https://www.irbnet.org/release/index.html ii. New users: Click on New Registration in the top right corner iii. Fill-out the

More information

CS2 Current Technologies Lecture 2: SQL Programming Basics

CS2 Current Technologies Lecture 2: SQL Programming Basics T E H U N I V E R S I T Y O H F R G E D I N B U CS2 Current Technologies Lecture 2: SQL Programming Basics Dr Chris Walton (cdw@dcs.ed.ac.uk) 4 February 2002 The SQL Language 1 Structured Query Language

More information

Mathematics Shape and Space: Polygon Angles

Mathematics Shape and Space: Polygon Angles a place of mind F A C U L T Y O F E D U C A T I O N Department of Curriculum and Pedagogy Mathematics Shape and Space: Polygon Angles Science and Mathematics Education Research Group Supported by UBC Teaching

More information

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014 Lecture 5 Last updated: December 10, 2014 Throrought this lecture we will use the following database diagram Inserting rows I The INSERT INTO statement enables inserting new rows into a table. The basic

More information

Course Outline. ProTech Professional Technical Services, Inc. Veritas Backup Exec 20.1: Administration. Course Summary.

Course Outline. ProTech Professional Technical Services, Inc. Veritas Backup Exec 20.1: Administration. Course Summary. Course Summary Description The course is designed for the data protection professional tasked with architecting, implementing, backing up, and restoring critical data. This class covers how to back up

More information

Real-World Performance Training SQL Introduction

Real-World Performance Training SQL Introduction Real-World Performance Training SQL Introduction Real-World Performance Team Basics SQL Structured Query Language Declarative You express what you want to do, not how to do it Despite the name, provides

More information

Exam sell. Higher Quality Better Service! Certified IT practice exam authority.

Exam sell. Higher Quality Better Service! Certified IT practice exam authority. Higher Quality Better Service! Exam sell Certified IT practice exam authority Accurate study guides, High passing rate! Exam Sell provides update free of charge in one year! http://www.examsell.com Exam

More information

THE INDIAN COMMUNITY SCHOOL, KUWAIT

THE INDIAN COMMUNITY SCHOOL, KUWAIT THE INDIAN COMMUNITY SCHOOL, KUWAIT SERIES : II MID TERM /FN/ 18-19 CODE : M 065 TIME ALLOWED : 2 HOURS NAME OF STUDENT : MAX. MARKS : 50 ROLL NO. :.. CLASS/SEC :.. NO. OF PAGES : 3 INFORMATICS PRACTICES

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Advanced Query Tuning with IBM Data Studio. Tony Andrews Themis

Advanced Query Tuning with IBM Data Studio. Tony Andrews Themis Advanced Query Tuning with IBM Data Studio Tony Andrews Themis Session code:????????? Thu, May 03, 2018 (09:20 AM - 10:20 AM) Platform: Both Db2 LUW and z/os 1 1 Objectives By the end of this presentation,

More information

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries T E H U N I V E R S I T Y O H F R G E D I N B U CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries Chris Walton (cdw@dcs.ed.ac.uk) 11 February 2002 Multiple Tables 1 Redundancy requires excess

More information

User sguidefortheviewer

User sguidefortheviewer Tivoli Decision Support for OS/390 User sguidefortheviewer Version 1.6 SH19-4517-03 Tivoli Decision Support for OS/390 User sguidefortheviewer Version 1.6 SH19-4517-03 Note Before using this information

More information

Intermediate SQL: Aggregated Data, Joins and Set Operators

Intermediate SQL: Aggregated Data, Joins and Set Operators Intermediate SQL: Aggregated Data, Joins and Set Operators Aggregated Data and Sorting Objectives After completing this lesson, you should be able to do the following: Identify the available group functions

More information

CS2 Current Technologies Note 1 CS2Bh

CS2 Current Technologies Note 1 CS2Bh CS2 Current Technologies Note 1 Relational Database Systems Introduction When we wish to extract information from a database, we communicate with the Database Management System (DBMS) using a query language

More information

IBM DB2 9 Application Developer. Practice Test. Version 1.1.

IBM DB2 9 Application Developer. Practice Test. Version 1.1. IBM 000-733 000-733 DB2 9 Application Developer Practice Test Version 1.1 QUESTION NO: 1 IBM 000-733: Practice Exam A.NET application executes a SQL request invoking the DB2Command.ExecuteReader method

More information

CITY UNIVERSITY OF NEW YORK. Creating a New Project in IRBNet. i. After logging in, click Create New Project on left side of the page.

CITY UNIVERSITY OF NEW YORK. Creating a New Project in IRBNet. i. After logging in, click Create New Project on left side of the page. CITY UNIVERSITY OF NEW YORK Creating a New Project in IRBNet i. After logging in, click Create New Project on left side of the page. ii. Enter the title of the project, the principle investigator s (PI)

More information

SYSTEM 2000 Essentials

SYSTEM 2000 Essentials 7 CHAPTER 2 SYSTEM 2000 Essentials Introduction 7 SYSTEM 2000 Software 8 SYSTEM 2000 Databases 8 Database Name 9 Labeling Data 9 Grouping Data 10 Establishing Relationships between Schema Records 10 Logical

More information

Paul Bird June 2018 Db2 = JSON + SQL

Paul Bird June 2018 Db2 = JSON + SQL Paul Bird June 2018 Db2 = JSON + SQL Safe Harbor Statement Copyright IBM Corporation 2018. All rights reserved. U.S. Government Users Restricted Rights - Use, duplication, or disclosure restricted by GSA

More information

Information Catalog Center Administration Guide

Information Catalog Center Administration Guide IBM DB2 Warehouse Manager Information Catalog Center Administration Guide Version 8 SC27-1125-00 IBM DB2 Warehouse Manager Information Catalog Center Administration Guide Version 8 SC27-1125-00 Before

More information

Annexure I: Contact Details:

Annexure I: Contact Details: Ref: CO/IT-BPR/CSC Date:.09.2017 Annexure I: Contact Details: a) Name of the company b) Company s address in India c) Contact person d) Telephone no. e) Fax f) E-mail address g) Service tax registration

More information

Assignment 6: SQL III Solution

Assignment 6: SQL III Solution Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment

More information

C Examcollection.Premium.Exam.58q

C Examcollection.Premium.Exam.58q C2090-610.Examcollection.Premium.Exam.58q Number: C2090-610 Passing Score: 800 Time Limit: 120 min File Version: 32.2 http://www.gratisexam.com/ Exam Code: C2090-610 Exam Name: DB2 10.1 Fundamentals Visualexams

More information

IBM C DB2 9.5 SQL Procedure Developer.

IBM C DB2 9.5 SQL Procedure Developer. IBM C2090-735 DB2 9.5 SQL Procedure Developer https://killexams.com/pass4sure/exam-detail/c2090-735 QUESTION: 88 Click the Exhibit button. The file myscript.sql (shown in the exhibit) is executed from

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

CS430 Final March 14, 2005

CS430 Final March 14, 2005 Name: W#: CS430 Final March 14, 2005 Write your answers in the space provided. Use the back of the page if you need more space. Values of questions are as indicated. 1. (4 points) What are the four ACID

More information

Database implementation Further SQL

Database implementation Further SQL IRU SEMESTER 2 January 2010 Semester 1 Session 2 Database implementation Further SQL Objectives To be able to use more advanced SQL statements, including Renaming columns Order by clause Aggregate functions

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

Assignment 6: SQL III

Assignment 6: SQL III Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III This assignment

More information

COMP 3400 Mainframe Administration 1

COMP 3400 Mainframe Administration 1 COMP 3400 Mainframe Administration 1 Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 These slides are based in part on materials provided by IBM s Academic Initiative. 1 Databases

More information

Chapter 2. DB2 concepts

Chapter 2. DB2 concepts 4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions

More information

Queries. Chapter 6. In This Chapter. c SELECT Statement: Its Clauses and Functions. c Join Operator c Correlated Subqueries c Table Expressions

Queries. Chapter 6. In This Chapter. c SELECT Statement: Its Clauses and Functions. c Join Operator c Correlated Subqueries c Table Expressions Chapter 6 Queries In This Chapter c SELECT Statement: Its Clauses and Functions c Subqueries c Temporary Tables c Join Operator c Correlated Subqueries c Table Expressions 136 Microsoft SQL Server 2012:

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Course: 20761 Course Details Audience(s): IT Professional(s) Technology: Microsoft SQL Server 2016 Duration: 24 HRs. ABOUT THIS COURSE This course is designed to introduce

More information

Employer Self Service (ESS) User Quick Guide

Employer Self Service (ESS) User Quick Guide Employer Self Service (ESS) User Quick Guide i Table of Contents Getting Started 6 Accessing the Employer Self Service (ESS) Portal 6 Maintaining Account Settings 7 Switching Employers within Session 7

More information

Business Intelligence Roadmap HDT923 Three Days

Business Intelligence Roadmap HDT923 Three Days Three Days Prerequisites Students should have experience with any relational database management system as well as experience with data warehouses and star schemas. It would be helpful if students are

More information

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins GIFT Department of Computing Science CS-217/224: Database Systems Lab-5 Manual Displaying Data from Multiple Tables - SQL Joins V3.0 5/5/2016 Introduction to Lab-5 This lab introduces students to selecting

More information

DB2 for z/os is Serious About Analytics: Leveraging SQL to Analyze Your Data Where it Resides

DB2 for z/os is Serious About Analytics: Leveraging SQL to Analyze Your Data Where it Resides DB2 for z/os is Serious About Analytics: Leveraging SQL to Analyze Your Data Where it Resides Maryela Weihrauch, IBM Distinguished Engineer, weihrau@us.ibm.com Notices and disclaimers Copyright 2016 by

More information

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002. CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 10 DUE: Run the following queries in Oracle Application Express. Paste a copy of each query Into this word document below the questions or notepad.txt

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course 20761A: Querying Data with Transact-SQL Page 1 of 5 Querying Data with Transact-SQL Course 20761A: 2 days; Instructor-Led Introduction The main purpose of this 2 day instructor led course is to

More information

EE221 Databases Practicals Manual

EE221 Databases Practicals Manual EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School

More information