0% found this document useful (0 votes)
9 views

Practical problems 3

The document outlines tasks for generating invoice reports and retrieving customer data from the Adventure Works Cycles database. It includes specific queries to extract customer orders, addresses, and sales information, as well as tasks related to the AdventureWorksDW2019 database. The tasks emphasize the need to handle many-to-many relationships and ensure comprehensive reporting for the sales team.

Uploaded by

vandt2308
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)
9 views

Practical problems 3

The document outlines tasks for generating invoice reports and retrieving customer data from the Adventure Works Cycles database. It includes specific queries to extract customer orders, addresses, and sales information, as well as tasks related to the AdventureWorksDW2019 database. The tasks emphasize the need to handle many-to-many relationships and ensure comprehensive reporting for the sales team.

Uploaded by

vandt2308
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/ 2

Practical problems 3 (Join and Union)

Task 1: Generate invoice reports


Adventure Works Cycles sells directly to retailers, who must be invoiced for their orders.
You have been tasked with writing a query to generate a list of invoices to be sent to
customers.
1.1 Retrieve customer orders
As an initial step towards generating the invoice report, write a query that returns the
company name from the SalesLT.Customer table,
and the sales order ID and total due from the SalesLT.SalesOrderHeader table.
1.2 Retrieve customer orders with addresses

Extend your customer orders query to include the Main Office address for each customer,
including the full street address, city, state or province,
postal code, and country or region

Tip: Note that each customer can have multiple addressees in the SalesLT.Address table, so
the database developer has created
the SalesLT.CustomerAddress table to enable a many-to-many relationship between
customers and addresses.
Your query will need to include both of these tables, and should filter the results so that
only Main Office addresses are included.

Task 2: Retrieve customer data

As you continue to work with the Adventure Works customer and sales data, you must create
queries for reports that have been requested by the sales team.

2.1 Retrieve a list of all customers and their orders

The sales manager wants a list of all customer companies and their contacts (first name and
last name),
showing the sales order ID and total due for each order they have placed.
Customers who have not placed any orders should be included at the bottom of the list with
NULL values for the order ID and total due.

2.2 Retrieve a list of customers with no address

A sales employee has noticed that Adventure Works does not have address information for all
customers.
You must write a query that returns a list of customer IDs, company names, contact names
(first name and last name),
and phone numbers for customers with no address stored in the database.

Task 3: use AdventureWorksDW2019 to do the following excercises


3.1 : From dbo.FactInternetSales and dbo.FactInternetSalesReason tables,
Write a query displaying the SalesOrderNumber, SalesOrderLineNumber
where the SalesReasonKey equal to 2 or 5

3.2:
From DimDepartmentGroup, Write a query display DepartmentGroupName and
their parent DepartmentGroupName

3.3 Use adventureworks database


 Show all the addresses listed for 'Modular Cycle Systems'
 Show OrdeQty, the Name and the ListPrice of the order made by CustomerID = 30072
 Retrieve a list of customers with no address
 Write the query, noting that it returns the total sales revenue for each salesperson who has
completed any sales.
 Write the query, noting that it returns the sales totals for salespeople who have sold items,
and 0.00 for those who haven’t.
 The product manager would like reports that include aggregated information about
product sales. Retrieve total sales by product
 Filter the product sales groups to include only total sales over 20,000 and Listprice over
1000

You might also like