Question
Need help in Sql queries ! Thanx :) /* Question #1 - Without adding any additional tables to the FROM statement below, add the column
Need help in Sql queries ! Thanx :)
/*
Question #1 -
Without adding any additional tables to the FROM statement below,
add the column "PackageTypeName" (from Warehouse.PackageTypes) to the
results
*/
SELECT
IL.PackageTypeID,
SUM(IL.ExtendedPrice)
FROM
Sales.Invoices I
INNER JOIN Sales.InvoiceLines IL ON I.InvoiceID = IL.InvoiceID
GROUP BY
IL.PackageTypeID
/*
Question #2
Write a query that returns each salesperson's best year and worst year,
based on the Invoice tables. Use the ExtendedPrice column from the
InvoiceLines table for each line's contribution (I don't want you
to calculate the contribution as we've done in other queries).
Order the results by the lowest of the worst years first.
You are not allowed to use a union, case statement, or windowed function.
You will get 10 rows back - first and last records look like the following:
14 Lily Code 2422204.13 6574146.27
15 Taj Shand 2896948.01 6045415.13
*/
/*
Question #3 -
The sales manager wants to look at the current year (2016 in this case) sales
compared to the lifetime sales for each salesperson. This is calculated by
aggregating the sales for 2016 (based on the Invoice tables) divided by
the sum of all sales for all time. Order the list in descending order of the
% of life time sales that 2016 represents. Your query will return 10 records
and the top two results look like:
PersonID FullName 2016Sales %OfLifeTimeSales
15 Taj Shand 2896948.01 0.145703
16 Archer Lamble 2850011.20 0.138150
You are not allowed to use a union, case statement, or windowed function.
*/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started