0% found this document useful (0 votes)
422 views11 pages

Northwind-Full 39 Queries: Exercise 1

This document contains 39 SQL query exercises involving tables from the Northwind database. The exercises include queries to return employee and customer data based on conditions, product data including units and orders, order details like totals and dates, and aggregating data to find minimums, maximums, and highest levels. The goal is to write SQL queries to return the requested data in the specified format for each exercise.

Uploaded by

Lucusx T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
422 views11 pages

Northwind-Full 39 Queries: Exercise 1

This document contains 39 SQL query exercises involving tables from the Northwind database. The exercises include queries to return employee and customer data based on conditions, product data including units and orders, order details like totals and dates, and aggregating data to find minimums, maximums, and highest levels. The goal is to write SQL queries to return the requested data in the specified format for each exercise.

Uploaded by

Lucusx T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Northwind-Full 39 Queries

Exercise 1
Write a SELECT query to display Full name of all employees in lower-case as following:

Exercise 2
Write a SELECT query to display Full name of all employees in upper-case as following:

Exercise 3
Write a SELECT query to display all employees that are from United States as following:
Exercise 4
Write a SELECT query to display all customers that are from UK as following:

Exercise 5
Write a SELECT query to display all customers that are from Mexico as following:

Exercise 6
Write a SELECT query to display all customers that are from Sweden as following:

Exercise 7
In Products table, values of UnitsInStock tell you the total units in the inventory of every product.
Write a SELECT query to display product id, product name, unit price of all products such that
their total units in the inventory is between 5 and 10 as following:

Exercise 8
In Products table, the value of UnitsOnOrder tells you the total ordered units for every product. Write
a SELECT query to display product id, product name, unit price, re-order level… of all products that
have total ordered units between 60 and 100 as following:

Exercise 9
Write a SELECT query to display total orders of every employee in 1996 as following:

Exercise 10
Write a SELECT query to display total orders of every employee in 1998 as following:
Exercise 11
Write a SELECT query to display total orders of every employee from 1/1/1998 to 31/7/1998 as
following:

Exercise 12
Write a SELECT query to display total orders of every employee from 1/1/1997 to 30/6/1997 as
following:

Exercise 13
An order will be taxed 10% if its freight cost is larger than or equal to 100$.
Otherwise, an order will be taxed 5% if its freight cost is smaller than 100$.
Write a SELECT query to show the freight with taxes of orders placed between 1/8/1996 and
5/8/1996 as following:
Exercise 14
Write a SELECT query to display the full name, title of courtesy and sex for all employees such
that:
- If title of courtesy is ‘Mr.’ then sex is set
to ‘Male’

- If title of courtesy is ‘Ms.’ or ‘Mrs.’ then


sex is set to ‘Female’

Exercise 15
Write a SELECT query to display the full name, title of courtesy and sex for all employees such
that:
- If title of courtesy is ‘Mr.’ or ‘Dr.’ then sex is set to ‘M’

- If title of courtesy is ‘Ms.’ or ‘Mrs.’ then sex is set to


‘F’

Exercise 16
Write a SELECT query to display the full name, title of
courtesy and sex for all employees such that:
- If title of courtesy is ‘Mr.’ then sex is set to ‘Male’

- If title of courtesy is ‘Ms.’ or ‘Mrs.’ then sex is set to


‘Female’

- If title of courtesy is not ‘Mr.’ and not ‘Mrs.’ and not ‘Ms.’
then sex is set to ‘Unknown’

Exercise 17
Write a SELECT query to display the full name, title of courtesy and sex for all employees such
that:
- If title of courtesy is ‘Mr.’ then sex is set to 1
- If title of courtesy is ‘Ms.’ or ‘Mrs.’ then sex is set to 0

- If title of courtesy is not ‘Mr.’ and not ‘Mrs.’ and not ‘Ms.’ then sex is set to 2

Exercise 18
Write a SELECT query to display the full name,
title of courtesy and sex for all employees such
that:
- If title of courtesy is ‘Mr.’ then sex is set to ‘M’

- If title of courtesy is ‘Ms.’ or ‘Mrs.’ then sex is set to


‘F’

- If title of courtesy is not ‘Mr.’ and not ‘Mrs.’ and not


‘Ms.’ then sex is set to ‘N/A’

Exercise 19
Exercise 20
Exercise 21
Write a query to determine the revenues for all products from 1/7/1996 to 5/7/1996 as following
(Revenue = Quantity * Unitprice). Note: The output must be order by category id and then
product id.
Exercise 22
Write a query to display information about 7-days late orders and their employees (an order is
called late if it is shipped after required date):

Exercise 23
Write a query to display the names and telephone
numbers of all employees and all customers satisfy the
condition: all customers have names start with ‘W’.
Exercise 24
Write a query to display information about the customer that placed the order with Id equal to
10643 as following:

Exercise 25
Write a query to display the product ids, product names and total units ordered of all products that
satisfy: the total units ordered must be greater than or equal to 1200 units.

Exercise 26
Write a query to display the product ids, product names, supplier id, category id and total units
ordered of all products that satisfy: the total units ordered must be greater than or equal to 1400
units.

Exercise 27
Write a query to display the categories that have maximum total product as following:

Exercise 28
Write a query to display the
categories that have minimum total
product as following:
Exercise 29
Write a query to display the total record in Customer and Employees
tables:

Exercise 30
Write a query to display information about employees who have minimum total orders as
following:

Exercise 31
Write a query to display information about employees who have maximum total orders as
following:

Exercise 32
In Products table, the value of UnitsInStock tells you the total unit in the inventory for every
product. Write a query to display information about products that have maximum total unit in
inventory as following:

Exercise 33
In Products table, the value of UnitsInStock tells you the total unit in the inventory for every
product. Write a query to display information about products that have minimum total unit in
inventory as following:
Exercise 34
In Products table, the value of UnitsOnOrder tells you the total ordered unit for every product.
Write a query to display information about products that have maximum total ordered unit as
following:

Exercise 35
In Products table, the value of ReOrderLevel tells you the re-order level for every product. Write
a query to display information about products that have maximum re-order level as following:

Exercise 36
Write a query to display the information about employees who have maximum total delayed-orders as
following:

Exercise 37
Write a query to display the information about employees who have at least one delayed-order and
have minimum total delayed-orders as following:
Exercise 38
Write a query to display product ids and product names of all products that have total ordered-
units in three-highest level (top 3 to top 1) as following:

Exercise 39
Write a query to display product ids and product names of all products that have total ordered-
units in five-highest level (top 5 to top 1) as following:

You might also like