Solutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik. John Weatherwax

Size: px
Start display at page:

Download "Solutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik. John Weatherwax"

Transcription

1 Solutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik John Weatherwax 1

2 Text copyright c 2018 John L. Weatherwax All Rights Reserved Please Do Not Redistribute Without Permission from the Author 2

3 To my family. 3

4 Introduction This is my solution manual to some of the problems in the excellent book: SQL Practice Problems by Sylvia Moestl Vasilik While the original book has solution in SQL Server I found it easiest to work the problems in SQLite and thus these solutions are in that dialect of SQL. I hope you find them useful. /* P 1: */ * Shippers; /* P 2 (EPage 20): */ CategoryName, Description Categories; /* P 3: */ FirstName, LastName, HireDate Employees Title = Sales Representative ; /* P 4 (EPage 25): */ FirstName, LastName, HireDate Employees Title = Sales Representative AND = USA ; /* P 5 (EPage 28): */ OrderID, OrderDate EmployeeID = 5; 4

5 /* P 6 (EPage 32): */ SupplierID, ContactName, ContactTitle Suppliers ContactTitle <> Manager ; /* P 7 (EPage 35): */ ProductID, ProductName Products ProductName LIKE %queso% ; /* P 8 (EPage 38): */ OrderID, CustomerID, Ship Ship IN ( France, Belgium ); /* P 9 (EPage 41): */ OrderID, CustomerID, Ship Ship IN ( Brazil, Mexico, Argentina, Venezuela ); /* P 10 (EPage 44): */ FirstName, LastName, Title, BirthDate Employees BirthDate ASC; 5

6 /* P 11 (EPage 44): */ FirstName, LastName, Title, strftime( %Y-%m-%d, BirthDate) AS DateOnlyBirthDate Employees BirthDate ASC; /* P 12 (EPage 50): */ FirstName, LastName, FirstName LastName AS FullName Employees; /* P 13 (EPage 53): */ OrderID, ProductID, UnitPrice, Quantity, UnitPrice * Quantity AS TotalPrice [Order Details] OrderID, ProductID; /* P 14 (EPage 56): */ COUNT(*) AS Total ; /* P 15 (EPage 59): */ MIN(OrderDate) AS FirstOrder ; /* P 16 (EPage 62): */ 6

7 ; /* P 17 (EPage 65): */ ContactTitle, COUNT(*) AS TotalContractTitle ContactTitle TotalContractTitle DESC; /* P 18 (EPage): */ p.productid, p.productname, s.companyname Products p LEFT JOIN Suppliers s ON p.supplierid = s.supplierid; /* P 19 (EPage 71): */ OrderID, date(orderdate) AS OrderDate, CompanyName LEFT JOIN Shippers ON.ShipVia = Shippers.ShipperID OrderID < OrderID; /* P 20 (EPage 76) */ CategoryName, COUNT(*) AS Count Categories JOIN Products ON Categories.CategoryID = Products.CategoryID CategoryName 7

8 Count DESC; /* P 21 (EPage 79) */, City, COUNT(*) AS Total, City Total DESC; /* P 22 (EPage 82) */ ProductID, ProductName, UnitsInStock, ReorderLevel Products UnitsInStock <= ReorderLevel ProductID; /* P 23 (EPage 85) */ ProductID, ProductName, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued Products (UnitsInStock + UnitsOnOrder) <= ReorderLevel AND Discontinued= 0 ProductID; /* P 24 (EPage 88) */ 8

9 CustomerID, CompanyName, Region (CASE WHEN Region IS NULL THEN 1 ELSE 0 END), Region, CustomerID; /* P 25 (EPage 92) */ Ship, AVG(Freight) AS AverageFreight Ship AverageFreight DESC LIMIT 3; /* P 26 (EPage 97) */ Ship, AVG(Freight) AS AverageFreight strftime( %Y, OrderDate) = 1997 Ship AverageFreight DESC LIMIT 3; /* P 28 (EPage 105) */ Ship, AVG(Freight) AS AverageFreight OrderDate >= ( datetime(julianday(max(orderdate)) - 365) ) Ship 9

10 AverageFreight DESC LIMIT 3; /* P 29 (EPage 110) */.EmployeeID, Employees.LastName,.OrderID, Products.ProductName, [Order Details].Quantity LEFT JOIN Employees ON.EmployeeID = Employees.EmployeeID LEFT JOIN [Order Details] ON.OrderID = [Order Details].OrderID LEFT JOIN Products ON [Order Details].ProductID = Products.ProductID.OrderID, [Order Details].ProductID LIMIT 20; /* P 30 (EPage 113) */.CustomerID AS _CustomerID,.CustomerID AS _CustomerID LEFT JOIN ON.CustomerID =.CustomerID.CustomerID IS NULL.CustomerID; /* P 31 (EPage 117) */.CustomerID AS _CustomerID,.CustomerID AS _CustomerID LEFT JOIN ON.CustomerID =.CustomerID AND.EmployeeID = 4.CustomerID IS NULL.CustomerID; 10

11 /* P 32 (EPage 121) */.CustomerID,.CompanyName,.OrderID, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalOrderAmount JOIN ON.CustomerID =.CustomerID JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID,.OrderID HAVING TotalOrderAmount > TotalOrderAmount DESC; /* P 33 (EPage 126) */.CustomerID,.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalOrderAmount JOIN ON.CustomerID =.CustomerID JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID HAVING TotalOrderAmount > TotalOrderAmount DESC; /* P 34 (EPage 129) */.CustomerID,.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalWithoutDiscount, SUM([Order Details].UnitPrice * [Order Details].Quantity * (1-[Order Details].Discount)) AS TotalWithDiscount JOIN ON.CustomerID =.CustomerID 11

12 JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID HAVING TotalWithDiscount > TotalWithDiscount DESC; /* P 35 (EPage 133) */.EmployeeID,.OrderID, date(.orderdate) date(.orderdate, start of month, +1 month, -1 day ) = date(.orderdate).employeeid,.orderid; /* P 36 (EPage 136) */.OrderID, COUNT(.OrderID) AS TotalOrderDetails JOIN [Order Details] ON.OrderID = [Order Details].OrderID.OrderID TotalOrderDetails LIMIT 10; /* P 37 (EPage 139) */ /* To select a fixed number of random rows we can use */ OrderID RANDOM() LIMIT 10; 12

13 /* To select a fixed percentage of random rows we can use */ OrderID RANDOM() LIMIT CAST(0.02 * ( COUNT(*) ) AS INTEGER); /* P 38 (EPage 142) */ OrderID, Quantity, COUNT(*) AS Number [Order Details] Quantity >= 60 OrderID, Quantity HAVING Number > 1; /* P 39 (EPage 146) */ /* Using a CTE (common table expression) */ WITH PossibleOrderIDs AS ( OrderID [Order Details] Quantity >= 60 OrderID, Quantity HAVING COUNT(*) > 1 ) OrderID, ProductID, UnitPrice, Quantity, Discount [Order Details] 13

14 OrderID IN PossibleOrderIDs OrderID, Quantity; /* P 40 (EPage 149) */ For this problem we add the keyword DISTINCT in the statement in the subquery in the provided SQL. /* P 41 (EPage 152) */ OrderID, OrderDate, RequiredDate, ShippedDate ShippedDate >= RequiredDate OrderDate ASC; /* P 42 (EPage 156) */.EmployeeID, Employees.LastName, COUNT(*) As TotalLate JOIN Employees ON.EmployeeID = Employees.EmployeeID ShippedDate >= RequiredDate.EmployeeID, Employees.LastName TotalLate DESC; /* P (EPage 159) */ /* Using two CTE (common table expressions) */ WITH -- Total orders TotalNumberOf AS ( EmployeeID, COUNT(*) AS Total 14

15 EmployeeID ), -- Late orders TotalLate AS ( EmployeeID, COUNT(*) AS TotalLate ShippedDate >= RequiredDate EmployeeID ) DISTINCT.EmployeeID, Employees.LastName, Total, TotalLate, ROUND(CAST(TotalLate AS FLOAT)/Total, 2) AS PercentLate JOIN Employees ON.EmployeeID = Employees.EmployeeID JOIN TotalNumberOf ON.EmployeeID = TotalNumberOf.EmployeeID LEFT JOIN TotalLate ON.EmployeeID = TotalLate.EmployeeID PercentLate DESC; /* P (EPage 177) */ WITH CustomerOrderSizes AS (.CustomerID,.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalOrderAmount JOIN ON.CustomerID =.CustomerID JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID.CustomerID ) 15

16 CustomerID, TotalOrderAmount, CASE WHEN ((TotalOrderAmount > 0) AND (TotalOrderAmount <= 1000)) THEN low WHEN ((TotalOrderAmount > 1000) AND (TotalOrderAmount <= 5000)) THEN medium WHEN ((TotalOrderAmount > 5000) AND (TotalOrderAmount < 10000)) THEN high ELSE very high END AS CustomerGroup CustomerOrderSizes CustomerID; /* P 50 (EPage 185) */ WITH CustomerOrderSizes AS (.CustomerID,.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalOrderAmount JOIN ON.CustomerID =.CustomerID JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID.CustomerID ), CustomerGroups AS ( TotalOrderAmount, CASE WHEN ((TotalOrderAmount > 0) AND (TotalOrderAmount <= 1000)) THEN low WHEN ((TotalOrderAmount > 1000) AND (TotalOrderAmount <= 5000)) THEN medium WHEN ((TotalOrderAmount > 5000) AND (TotalOrderAmount < 10000)) THEN high ELSE very high END AS CustomerGroup CustomerOrderSizes ) CustomerGroup, COUNT(*) AS TotalInGroup, ROUND(CAST(COUNT(*) AS DOUBLE)/( COUNT(*) CustomerGroups), 2) 16

17 AS PercentageInGroup CustomerGroups CustomerGroup PercentageInGroup DESC; /* P 51 (EPage 189) */ WITH CustomerOrderSizes AS (.CustomerID,.CompanyName, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS TotalOrderAmount JOIN ON.CustomerID =.CustomerID JOIN [Order Details] ON.OrderID = [Order Details].OrderID strftime( %Y,.OrderDate) = 1998.CustomerID.CustomerID ), CustomerGroups AS ( CustomerGroupName AS CustomerGroup, TotalOrderAmount CustomerOrderSizes JOIN CustomerGroupThresholds ON (RangeBottom < TotalOrderAmount) AND (TotalOrderAmount <= RangeTop) ) CustomerGroup, COUNT(*) AS TotalInGroup, ROUND(CAST(COUNT(*) AS DOUBLE)/( COUNT(*) CustomerGroups), 2) AS PercentageInGroup CustomerGroups CustomerGroup PercentageInGroup DESC; /* P 52 (EPage 193) */ 17

18 Suppliers UNION ; /* P 53 (EPage 196) */ WITH SupplierCountries AS ( DISTINCT Suppliers ), CustomerCountries AS ( DISTINCT ) -- Using ideas from: SupplierCountries. AS Supplier, CustomerCountries. AS Customer SupplierCountries LEFT JOIN CustomerCountries USING() UNION SupplierCountries. AS Supplier, CustomerCountries. AS Customer CustomerCountries LEFT JOIN SupplierCountries USING() NOT ((Supplier IS NULL) AND (Customer IS NULL)); /* P 54 (EPage 200) */ WITH -- get suppliers countries (and count) SupplierCountries AS ( 18

19 , COUNT(*) AS TotalSuppliers Suppliers IS NOT NULL ), -- get customer countries (and count) CustomerCountries AS (, COUNT(*) AS Total IS NOT NULL ), -- get a union of all countries AllCountries AS ( Suppliers IS NOT NULL UNION IS NOT NULL ) ac., IFNULL(sc.TotalSuppliers, 0) AS TotalSuppliers, IFNULL(cc.Total, 0) AS Total AllCountries ac LEFT JOIN SupplierCountries sc ON ac. = sc. LEFT JOIN CustomerCountries cc ON ac. = cc. ac.; /* P 55 (EPage 204) */ 19

20 -- -- Using ideas from: WITH CountriesFirstOrder AS ( -- get the first order date in each country Ship, MIN(OrderDate) AS FirstOrderDate Ship ) -- select the other information for this first order cfo.ship, CustomerID, OrderID, date(orderdate) AS OrderDate CountriesFirstOrder cfo LEFT JOIN o ON (cfo.firstorderdate = o.orderdate) AND (cfo.ship = o.ship) cfo.ship; /* P 56 (EPage 209) */ io.customerid, io.orderid AS InitialOrderID, date(io.orderdate) AS InitialOrderDate, so.orderid AS NextOrderID, date(so.orderdate) AS NextOrderDate, CAST(julianday(so.OrderDate) - julianday(io.orderdate) AS INTEGER) AS DaysBetween -- io = initial order io -- so = second order JOIN so ON (io.customerid = so.customerid) AND (io.orderid < so.orderid) DaysBetween <= 5; /* P 57 (EPage 217) SQLite does not currently support windowing functions */ 20

ISM 4212/4480 Milestone V Submission Sample

ISM 4212/4480 Milestone V Submission Sample This document shows an example of what the entire turn-in documentation for a single team member s portion of Milestone V might look like. It uses the NorthWinds Traders database. Joe Smith Transaction:

More information

Northwind Database. Sample Output from TechWriter 2007 for Databases

Northwind Database. Sample Output from TechWriter 2007 for Databases Table of Contents Northwind Database...3 Tables... 4 Categories...5 CustomerCustomerDemo... 6 CustomerDemographics... 7 Customers... 8 Employees...9 EmployeeTerritories... 11 Order Details... 12 Orders...

More information

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011 Introduction to SQL IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview Using Structured Query Language (SQL) to get the data you want from relational databases Learning basic syntax

More information

Module 11: Implementing Triggers

Module 11: Implementing Triggers Module 11: Implementing Triggers Overview Introduction Defining Create, drop, alter triggers How Triggers Work Examples Performance Considerations Analyze performance issues related to triggers Introduction

More information

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3 1 Chapter 3 Introduction to relational databases and MySQL Slide 2 Objectives Applied 1. Use phpmyadmin to review the data and structure of the tables in a database, to import and run SQL scripts that

More information

How to use SQL to work with a MySQL database

How to use SQL to work with a MySQL database Chapter 18 How to use SQL to work with a MySQL database Objectives (continued) Knowledge 7. Describe the use of the GROUP BY and HAVING clauses in a SELECT statement, and distinguish between HAVING clauses

More information

Assignment Grading Rubric

Assignment Grading Rubric Final Project Outcomes addressed in this activity: Overview and Directions: 1. Create a new Empty Database called Final 2. CREATE TABLES The create table statements should work without errors, have the

More information

Introduction to relational databases and MySQL

Introduction to relational databases and MySQL Chapter 3 Introduction to relational databases and MySQL A products table Columns 2017, Mike Murach & Associates, Inc. C3, Slide 1 2017, Mike Murach & Associates, Inc. C3, Slide 4 Objectives Applied 1.

More information

Submit the MS Access Database file that contains the forms created in this lab.

Submit the MS Access Database file that contains the forms created in this lab. A. Lab # : BSBA BIS245A-5B B. Lab 5B of 7: Completing Forms C. Lab Overview--Scenario/Summary TCO(s): 5. Given a physical database containing tables and relationships, create forms which demonstrate effective

More information

Views in SQL Server 2000

Views in SQL Server 2000 Views in SQL Server 2000 By: Kristofer Gafvert Copyright 2003 Kristofer Gafvert 1 Copyright Information Copyright 2003 Kristofer Gafvert (kgafvert@ilopia.com). No part of this publication may be transmitted,

More information

QUETZALANDIA.COM. 5. Data Manipulation Language

QUETZALANDIA.COM. 5. Data Manipulation Language 5. Data Manipulation Language 5.1 OBJECTIVES This chapter involves SQL Data Manipulation Language Commands. At the end of this chapter, students should: Be familiar with the syntax of SQL DML commands

More information

Answer: The tables being joined each have two columns with the same name and compatible data types, and you want to join on both of the columns.

Answer: The tables being joined each have two columns with the same name and compatible data types, and you want to join on both of the columns. Page 1 of 22 Item: 1 (Ref:Cert-1Z0-071.6.2.4) In which situation would you use a natural join? The tables being joined do not have primary and foreign keys defined. The tables being joined have matching

More information

Project 7: Northwind Traders Order Entry

Project 7: Northwind Traders Order Entry Project 7: Northwind Traders Order Entry 1 Northwinds Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders. Add orders to the database. Print invoices. Refer

More information

Structured Query Language (SQL)

Structured Query Language (SQL) Structured Query Language (SQL) SQL Chapters 6 & 7 (7 th edition) Chapters 4 & 5 (6 th edition) PostgreSQL on acsmysql1.acs.uwinnipeg.ca Each student has a userid and initial password acs!

More information

9 No limit. Number of UNIONs 9 No limit. 30 No limit. 1 No limit

9 No limit. Number of UNIONs 9 No limit. 30 No limit. 1 No limit August, 2004 Do More with VFP's SQL Commands In my last article, I looked at new and expanded uses of subqueries in VFP 9. This article considers additional changes related to VFP's SQL sublanguage. While

More information

SQL Server 2012 Development Course

SQL Server 2012 Development Course SQL Server 2012 Development Course Exam: 1 Lecturer: Amirreza Keshavarz May 2015 1- You are a database developer and you have many years experience in database development. Now you are employed in a company

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

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

Grouping and Sorting

Grouping and Sorting 1 Content... 2 2 Introduction... 2 3 Grouping data... 3 4 How to create reports with grouped data... 5 4.1 Simple Group Example... 5 4.2 Group example with Group Name Field... 8 4.3 Group example with

More information

MySQL. Prof.Sushila Aghav

MySQL. Prof.Sushila Aghav MySQL Prof.Sushila Aghav Introduction SQL is a standard language for storing, manipulating and retrieving data in databases. SQL is a part of many relational database management systems like: MySQL, SQL

More information

Microsoft_ Querying Microsoft SQL Server 2012

Microsoft_ Querying Microsoft SQL Server 2012 Microsoft_70-461 Querying Microsoft SQL Server 2012 QUESTION NO: 1 You work as a database administrator at ABC.com. ABC.com has a SQL Server 2012 database named ProductsDB. The relevant part of the ProductsDB

More information

COOKBOOK Creating an Order Form

COOKBOOK Creating an Order Form 2010 COOKBOOK Creating an Order Form Table of Contents Understanding the Project... 2 Table Relationships... 2 Objective... 4 Sample... 4 Implementation... 4 Generate Northwind Sample... 5 Order Form Page...

More information

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types Dr. Shohreh Ajoudanian Course Topics Microsoft SQL Server 01 Installing MSSQL Server 2008 03 Creating a database 05 Querying Tables with SELECT 07 Using Set Operators 02 Data types 04 Creating a table,

More information

Skills Exam Objective Objective Number. Creating crosstab queries Create a crosstab query

Skills Exam Objective Objective Number. Creating crosstab queries Create a crosstab query 12 Advanced Queries SKILL SUMMARY Skills Exam Objective Objective Number Creating crosstab queries Create a crosstab query. 3.1.2 Creating a subquery Add fields. Remove fields. Group data by using comparison

More information

Jarek Szlichta

Jarek Szlichta Jarek Szlichta http://data.science.uoit.ca/ SQL is a standard language for accessing and manipulating databases What is SQL? SQL stands for Structured Query Language SQL lets you gain access and control

More information

FIGURE 2.57 Denver Rooms 3 Guests Query. '3 LocationlD C", Address. Orders. Service. ServlceNlIme PerPersonCharge

FIGURE 2.57 Denver Rooms 3 Guests Query. '3 LocationlD C, Address. Orders. Service. ServlceNlIme PerPersonCharge The Prestige Hotel chain caters to upscale business travelers and provides state-of-the-art conference, meeting} and reception facilities. It prides itself on its international. four-star cuisine. Last

More information

Appendix A. Using DML to Modify Data. Contents: Lesson 1: Adding Data to Tables A-3. Lesson 2: Modifying and Removing Data A-8

Appendix A. Using DML to Modify Data. Contents: Lesson 1: Adding Data to Tables A-3. Lesson 2: Modifying and Removing Data A-8 A-1 Appendix A Using DML to Modify Data Contents: Lesson 1: Adding Data to Tables A-3 Lesson 2: Modifying and Removing Data A-8 Lesson 3: Generating Numbers A-15 A-2 Using DML to Modify Data Module Overview

More information

Consuming and Manipulating Data O BJECTIVES

Consuming and Manipulating Data O BJECTIVES O BJECTIVES This chapter covers the following Microsoft-specified objectives for the Consuming and Manipulating Data section of Exam 70-316, Developing and Implementing Windows-Based Applications with

More information

MIS2502: Review for Exam 2. JaeHwuen Jung

MIS2502: Review for Exam 2. JaeHwuen Jung MIS2502: Review for Exam 2 JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung Overview Date/Time: Wednesday, Mar 28, in class (50 minutes) Place: Regular classroom Please arrive 5

More information

Temporal Data Warehouses: Logical Models and Querying

Temporal Data Warehouses: Logical Models and Querying Temporal Data Warehouses: Logical Models and Querying Waqas Ahmed, Esteban Zimányi, Robert Wrembel waqas.ahmed@ulb.ac.be Université Libre de Bruxelles Poznan University of Technology April 2, 2015 ITBI

More information

-- Jerad Godsave -- November 9, CIS Assignment A8.sql

-- Jerad Godsave -- November 9, CIS Assignment A8.sql -- Jerad Godsave -- November 9, 2015 -- CIS 310-01 4158 -- Assignment A8.sql -- 1. List the products with a list price greater than the average list price of all products. -- result set: ItemID

More information

Chris Singleton 03/12/2017 PROG 140 Transactions & Performance. Module 8 Assignment

Chris Singleton 03/12/2017 PROG 140 Transactions & Performance. Module 8 Assignment Chris Singleton 03/12/2017 PROG 140 Transactions & Performance Module 8 Assignment Turn In: For this exercise, you will submit one WORD documents (instead of a.sql file) in which you have copied and pasted

More information

DATABASE MANAGEMENT SYSTEMS

DATABASE MANAGEMENT SYSTEMS DATABASE MANAGEMENT SYSTEMS Associate Professor Dr. Raed Ibraheem Hamed University of Human Development, College of Science and Technology Departments of IT and Computer Science 2015 2016 1 The ALTER TABLE

More information

MIS2502: Review for Exam 2. Jing Gong

MIS2502: Review for Exam 2. Jing Gong MIS2502: Review for Exam 2 Jing Gong gong@temple.edu http://community.mis.temple.edu/gong Overview Date/Time: Thursday, March 24, in class (1 hour 20 minutes) Place: Regular classroom Please arrive 5 minutes

More information

Database Logical Design

Database Logical Design Database Logical Design CIS 3730 Designing and Managing Data J.G. Zheng Fall 2010 1 Overview Relational model is a logical model Based on mathematical theories and rules Two ways to design a relational

More information

Database Logical Design

Database Logical Design Database Logical Design IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview Relational model is a logical model Based on mathematical theories and rules Two ways to design a relational

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

Exam code: Exam name: Database Fundamentals. Version 16.0 98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

More information

Chapter 3 Introduction to relational databases and MySQL

Chapter 3 Introduction to relational databases and MySQL Chapter 3 Introduction to relational databases and MySQL Murach's PHP and MySQL, C3 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Applied 1. Use phpmyadmin to review the data and structure of

More information

Stored Procedures and Functions. Rose-Hulman Institute of Technology Curt Clifton

Stored Procedures and Functions. Rose-Hulman Institute of Technology Curt Clifton Stored Procedures and Functions Rose-Hulman Institute of Technology Curt Clifton Outline Stored Procedures or Sprocs Functions Statements Reference Defining Stored Procedures Named Collections of Transact-SQL

More information

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://www.certqueen.com

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://www.certqueen.com IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://www.certqueen.com Exam : 70-457 Title : Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version : Demo

More information

More on MS Access queries

More on MS Access queries More on MS Access queries BSAD 141 Dave Novak Topics Covered MS Access query capabilities Aggregate queries Different joins Review: AND and OR Parameter query Exact match criteria versus range Formatting

More information

Advisor Answers. Match multiple items in a query. December, 2005 VFP 9/8/7

Advisor Answers. Match multiple items in a query. December, 2005 VFP 9/8/7 December, 2005 Advisor Answers Match multiple items in a query VFP 9/8/7 Q: I have a form with a multi-select listbox. After a user chooses some items, I want to find all the records in a table that have

More information

How to use SQL to create a database

How to use SQL to create a database Chapter 17 How to use SQL to create a database How to create a database CREATE DATABASE my_guitar_shop2; How to create a database only if it does not exist CREATE DATABASE IF NOT EXISTS my_guitar_shop2;

More information

Database Wizard Guide. i-net Designer

Database Wizard Guide. i-net Designer Guide i-net Designer 1 Content... 2 2 Introduction... 3 2.1 Definitions... 3 3 Setting Up a Simple Database Connection... 5 4 Choosing and Joining Table Sources... 6 5 Creating a Custom SQL Command... 10

More information

CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously. Correct

CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously. Correct 1. You query the database with this SQL statement: SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) Default Password FROM employees; Which function will be evaluated first? CONCAT SUBSTR LOWER

More information

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks)

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks) (12 Marks) 4.1 VIEW View: Views are virtual relations mainly used for security purpose, and can be provided on request by a particular user. A view can contain all rows of a table or select rows from a

More information

Load generation tools. By Drew Hamre

Load generation tools. By Drew Hamre March 2007 A Database Load Generation Utility By Drew Hamre Database load generators are software tools that generate workloads against a target DBMS. These tools emulate user activity against a database

More information

GETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application

GETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application 2012 GETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application generator for ASP.NET, Azure, DotNetNuke, and

More information

Automatic Conflict Resolution to Integrate Relational Schema. A dissertation submitted in partial satisfaction of the requirements for the degree of

Automatic Conflict Resolution to Integrate Relational Schema. A dissertation submitted in partial satisfaction of the requirements for the degree of UNIVERSITY of MANITOBA Automatic Conflict Resolution to Integrate Relational Schema A dissertation submitted in partial satisfaction of the requirements for the degree of Doctor of Philosophy in Computer

More information

Access Objects. Tables Queries Forms Reports Relationships

Access Objects. Tables Queries Forms Reports Relationships Access Review Access Objects Tables Queries Forms Reports Relationships How Access Saves a Database The Save button in Access differs from the Save button in other Windows programs such as Word and Excel.

More information

Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047)

Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047) Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047) Study Material for: Student 08.10.2010 15:49:30 Examine the following data listing for table WORKERS: WORKER_ID LAST_NAME

More information

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.

More information

SQL is a standard language for accessing and manipulating databases.

SQL is a standard language for accessing and manipulating databases. Introduction to SQL SQL is a standard language for accessing and manipulating databases. What is SQL? SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI

More information

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Sub queries A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Result of the inner query is passed to the main

More information

COPYRIGHTED MATERIAL. Chapter. Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER:

COPYRIGHTED MATERIAL. Chapter. Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER: Chapter 1 Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER: Define entities. Considerations include entity composition and normalization. Specify entity attributes. Specify degree

More information

KillTest. 半年免费更新服务

KillTest.   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 70-442GB2312 Title : PRO:Design & Optimize Data Access by Using MS SQL Serv 2005 Version : Demo 1 / 19 1. OrderItems OrderItems OrderID (PK,

More information

Working with Data in ASP.NET 2.0 :: Using TemplateFields in the DetailsView Control Introduction

Working with Data in ASP.NET 2.0 :: Using TemplateFields in the DetailsView Control Introduction This tutorial is part of a set. Find out more about data access with ASP.NET in the Working with Data in ASP.NET 2.0 section of the ASP.NET site at http://www.asp.net/learn/dataaccess/default.aspx. Working

More information

Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer.

Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Section 1 (Answer all questions in this section) 1. Which comparison

More information

Microsoft Exam Querying Microsoft SQL Server 2012 Version: 13.0 [ Total Questions: 153 ]

Microsoft Exam Querying Microsoft SQL Server 2012 Version: 13.0 [ Total Questions: 153 ] s@lm@n Microsoft Exam 70-461 Querying Microsoft SQL Server 2012 Version: 13.0 [ Total Questions: 153 ] Question No : 1 CORRECT TEXT Microsoft 70-461 : Practice Test You have a database named Sales that

More information

Smart Database [Stored Procedures - Functions Trigger]

Smart Database [Stored Procedures - Functions Trigger] Smart Database [Stored Procedures - Functions Trigger] Stored Procedures A stored procedure is an already written SQL statement that is saved in the database. Benefits of Stored Procedures: 1. Precompiled

More information

COOKBOOK Row-Level Security

COOKBOOK Row-Level Security 2010 COOKBOOK Row-Level Security Table of Contents Role vs. Row-Level Security... 2 Role... 2 Row-Level... 2 Steps to Implementing Row-Level Security... 2 Setting up the Application... 3 Creating Roles...

More information

Reporting Functions & Operators

Reporting Functions & Operators Functions Reporting Functions & Operators List of Built-in Field Functions Function Average Count Count Distinct Maximum Minimum Sum Sum Distinct Return the average of all values within the field. Return

More information

CS363: Structured Query Language for Data Management 1. CS363: Structured Query Language (SQL) for Data Management. Team Echo Group Project - Final

CS363: Structured Query Language for Data Management 1. CS363: Structured Query Language (SQL) for Data Management. Team Echo Group Project - Final CS363: Structured Query Language for Data Management 1 CS363: Structured Query Language (SQL) for Data Management Team Echo Group Project - Final Trina VanderLouw Other Team Members: Darrell Moore, Kanaan

More information

L e a r n S q l select where

L e a r n S q l select where L e a r n S q l The select statement is used to query the database and retrieve selected data that match the criteria that you specify. Here is the format of a simple select statement: select "column1"

More information

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

PASS4TEST. IT Certification Guaranteed, The Easy Way!  We offer free update service for one year PASS4TEST IT Certification Guaranteed, The Easy Way! \ http://www.pass4test.com We offer free update service for one year Exam : 1Z0-047 Title : Oracle Database SQL Expert Vendors : Oracle Version : DEMO

More information

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved. Restricting and Sorting Data Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the rows that are retrieved by a query Use

More information

Coveo Platform 7.0. Database Connector Guide

Coveo Platform 7.0. Database Connector Guide Coveo Platform 7.0 Database Connector Guide Notice The content in this document represents the current view of Coveo as of the date of publication. Because Coveo continually responds to changing market

More information

1z Exam Code: 1z Exam Name: Oracle Database SQL Expert

1z Exam Code: 1z Exam Name: Oracle Database SQL Expert 1z0-047 Number: 1z0-047 Passing Score: 800 Time Limit: 120 min File Version: 12.0 Exam Code: 1z0-047 Exam Name: Oracle Database SQL Expert 1z0-047 QUESTION 1 Which three statements are true regarding single-row

More information

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018.

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018. Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 4: SQL This assignment will

More information

MICROSOFT EXAM QUESTIONS & ANSWERS

MICROSOFT EXAM QUESTIONS & ANSWERS MICROSOFT 70-461 EXAM QUESTIONS & ANSWERS Number: 70-461 Passing Score: 700 Time Limit: 300 min File Version: 36.2 http://www.gratisexam.com/ MICROSOFT 70-461 EXAM QUESTIONS & ANSWERS Exam Name: Querying

More information

Extend your queries with APPLY

Extend your queries with APPLY Extend your queries with APPLY SQL Server offers a way to combine tables with table-valued functions, and to create the equivalent of correlated derived tables. Tamar E. Granor, Ph.D. As I ve been digging

More information

IMPORTING DATA IN PYTHON I. Introduction to relational databases

IMPORTING DATA IN PYTHON I. Introduction to relational databases IMPORTING DATA IN PYTHON I Introduction to relational databases What is a relational database? Based on relational model of data First described by Edgar Ted Codd Example: Northwind database Orders table

More information

8. Orders shipping to France or Belgium

8. Orders shipping to France or Belgium 8. Orders shipping to France or Belgium Looking at the Orders table, there s a field called ShipCountry. Write a query that shows the OrderID, CustomerID, and ShipCountry for the orders where the ShipCountry

More information

PassReview. PassReview - IT Certification Exams Pass Review

PassReview.  PassReview - IT Certification Exams Pass Review PassReview http://www.passreview.com PassReview - IT Certification Exams Pass Review Exam : 70-761 Title : Querying Data with Transact- SQL Vendor : Microsoft Version : DEMO Get Latest & Valid 70-761 Exam's

More information

Project Spring Item. Field Data Type Description Example Constraints Required. The ID for this table; autoincremented.

Project Spring Item. Field Data Type Description Example Constraints Required. The ID for this table; autoincremented. Item The ID for this table; autoincremented. 2 name The name of this Black House of Staunton vinyl chess board inventory_level The current number of this item in storage. 29 reorder_level The number of

More information

SELF TEST. List the Capabilities of SQL SELECT Statements

SELF TEST. List the Capabilities of SQL SELECT Statements 98 SELF TEST The following questions will help you measure your understanding of the material presented in this chapter. Read all the choices carefully because there might be more than one correct answer.

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

Natural-Join Operation

Natural-Join Operation Natural-Join Operation Natural join ( ) is a binary operation that is written as (r s) where r and s are relations. The result of the natural join is the set of all combinations of tuples in r and s that

More information

Oracle 1Z Oracle Database 12c SQL. Download Full Version :

Oracle 1Z Oracle Database 12c SQL. Download Full Version : Oracle 1Z0-071 Oracle Database 12c SQL Download Full Version : http://killexams.com/pass4sure/exam-detail/1z0-071 QUESTION: 64 Which task can be performed by using a single Data Manipulation Language (OML)

More information

--NOTE: We are now using a different database. USE AdventureWorks2012;

--NOTE: We are now using a different database. USE AdventureWorks2012; --* BUSIT 103 Assignment #6 DUE DATE : Consult course calendar /* Name: Christopher Singleton Class: BUSIT103 - Online Instructor: Art Lovestedt Date: 11/01/2014 */ --You are to develop SQL statements

More information

Importing into Neo4j - No witty subtitle - Dave July 27

Importing into Neo4j - No witty subtitle - Dave July 27 Importing into Neo4j - No witty subtitle - Dave Fauth @davefauth July 27 Life as a Field Engineer 2 Ask the right questions 3 Model the Problem Simple relationship has a name, but no properties Employee

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

Working with Actuate Query

Working with Actuate Query Working with Actuate Query This documentation has been created for software version 11.0.5. It is also valid for subsequent software versions as long as no new document version is shipped with the product

More information

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter

More information

Database Tables Lookup Wizard Relationships Forms Subforms Queries Reports

Database Tables Lookup Wizard Relationships Forms Subforms Queries Reports Version 07/11/09 Microsoft Office 2007 PDF Picture Tutorial Series Databases Tables, Forms, Subforms, and the Lookup Wizard May 2009 by Floyd Jay Winters and Julie Manchester winterf@mccfl.edu Database

More information

Preventing the Alteration of Dependent Objects:The SCHEMABINDING Option

Preventing the Alteration of Dependent Objects:The SCHEMABINDING Option USE Northwind DROP FUNCTION dbo.today Caution Before dropping a user-defined function, as with any other database object, check its dependencies. You cannot drop a user-defined function if it is used in

More information

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER Higher Quality Better Service! Exam Actual QUESTION & ANSWER Accurate study guides, High passing rate! Exam Actual provides update free of charge in one year! http://www.examactual.com Exam : 1Z0-047 Title

More information

Generating crosstabs in VFP

Generating crosstabs in VFP Generating crosstabs in VFP Several tools make it easy to change from normalized data to crosstabbed data with both rows and columns determined by the data in the set. Tamar E. Granor, Ph.D. One of the

More information

CIS 363 MySQL. Chapter 12 Joins Chapter 13 Subqueries

CIS 363 MySQL. Chapter 12 Joins Chapter 13 Subqueries CIS 363 MySQL Chapter 12 Joins Chapter 13 Subqueries Ch.12 Joins TABLE JOINS: Involve access data from two or more tables in a single query. The ability to join two or more tables together is called a

More information

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL Instructor: Craig Duckett Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL 1 Assignment 3 is due LECTURE 20, Tuesday, June 5 th Database Presentation is due LECTURE 20, Tuesday,

More information

Microsoft Exam Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version: 7.8 [ Total Questions: 183 ]

Microsoft Exam Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version: 7.8 [ Total Questions: 183 ] s@lm@n Microsoft Exam 70-457 Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version: 7.8 [ Total Questions: 183 ] Question No : 1 You have a database that contains the tables

More information

Kaotii.

Kaotii. Kaotii IT http://www.kaotii.com Exam : 70-762 Title : Developing SQL Databases Version : DEMO 1 / 10 1.DRAG DROP Note: This question is part of a series of questions that use the same scenario. For your

More information

ADMISTRATOR S GUIDE INTERACTIVE REPORTING VERSION 3.3. Volume. Sales Analysis and Reporting Products

ADMISTRATOR S GUIDE INTERACTIVE REPORTING VERSION 3.3. Volume. Sales Analysis and Reporting Products I N T E R A C T I V E R E P O R T I N G A D M I N S T R A T O R S G U I DE Volume 1 I N T E R A C T I V E R E P O R T I N G Sales Analysis and Reporting Products INTERACTIVE REPORTING VERSION 3.3 ADMISTRATOR

More information

Oracle Academy Amazing Books Part 1: Building Tables and Adding Constraints

Oracle Academy Amazing Books Part 1: Building Tables and Adding Constraints Oracle Academy Amazing Books In this section, you use the Object Browser in Oracle Application Express to: Build the base tables for the project Add foreign key constraints Be sure to have a copy of the

More information

Oracle EXAM - 1Z Oracle Database SQL Expert. Buy Full Product.

Oracle EXAM - 1Z Oracle Database SQL Expert. Buy Full Product. Oracle EXAM - 1Z0-047 Oracle Database SQL Expert Buy Full Product http://www.examskey.com/1z0-047.html Examskey Oracle 1Z0-047 exam demo product is here for you to test the quality of the product. This

More information

Exam #1 Review. Zuyin (Alvin) Zheng

Exam #1 Review. Zuyin (Alvin) Zheng Exam #1 Review Zuyin (Alvin) Zheng Data/Information/Database Data vs. Information Data Information Discrete, unorganized, raw facts The transformation of those facts into meaning Transactional Data vs.

More information

SECTION 1 DBMS LAB 1.0 INTRODUCTION 1.1 OBJECTIVES 1.2 INTRODUCTION TO MS-ACCESS. Structure Page No.

SECTION 1 DBMS LAB 1.0 INTRODUCTION 1.1 OBJECTIVES 1.2 INTRODUCTION TO MS-ACCESS. Structure Page No. SECTION 1 DBMS LAB DBMS Lab Structure Page No. 1.0 Introduction 05 1.1 Objectives 05 1.2 Introduction to MS-Access 05 1.3 Database Creation 13 1.4 Use of DBMS Tools/ Client-Server Mode 15 1.5 Forms and

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 2-1 Objectives This lesson covers the following objectives: Apply the concatenation operator to link columns to other columns, arithmetic expressions, or constant values to

More information

Oracle 1Z Oracle Database SQL Expert. Download Full Version :

Oracle 1Z Oracle Database SQL Expert. Download Full Version : Oracle 1Z0-047 Oracle Database SQL Expert Download Full Version : http://killexams.com/pass4sure/exam-detail/1z0-047 QUESTION: 270 View the Exhibit and examine the structure for the ORDERS and ORDER_ITEMS

More information

exam.87q.

exam.87q. 70-761.exam.87q Number: 70-761 Passing Score: 800 Time Limit: 120 min 70-761 Querying Data with Transact-SQL Exam A QUESTION 1 Note: This question is part of a series of questions that present the same

More information