Questions are based on the Northwind database.
a. A data dictionary (Excel file) that describes each of the tables. (Attached in question)
b. Write good, clean SQL that answers the following questions.
c. Separate your queries as I have done in the following example. End each query with a semicolon (;) and insert the word "go" between each query. Queries can span multiple lines if required.
Select CustomerID from Customers;
go
Select Count(*) from Employees;
go
Select max(productID) from Products;
18. Produce a count of the employees by each sales region
19. List the dollar values for sales by region?
20. What is the average value of a sales order?
21. List orders (OrderID, OrderDate, Customer Name) where the total order value is greater than the average value of a sales order?
22. Produce a customer report (must also include those we have not yet done business with) showing CustomerID, Customer name and total sales made to that customer
23. List all products that need to be re-ordered. Do not include discontinued products in this report.
24. List all customers that we made a sale to in the year 1996
25. List all customers that we did not make a sale to in the year 1996
18.
Select count(EmployeeID) from Employees group by region;
19.
Select region,Sum(unitPrice*quantity) from OrderDetails inner join Orders on OrderDetails.orderID = Orders.orderID inner join Employees on Orders.EmployeeID = Employees.EmployeeID group by region;
20.
Select avg(unitPrice*quantity) from OrderDetails;
21.
Select OrderID,OrderDate,CompanyName from Customers inner join Orders on Customers.customerID = Orders.customerID inner join OrderDetails on OrderDetails.orderID = Orders.orderID group by OrderID,OrderDate,CompanyName having sum(quantity*unitPrice) > avg(sum(quantity*unitPrice));
22.
Select CustomerID , CompanyName , Sum(UnitPrice*quantity) from Customers left join Orders on Customers.customerID = Orders.customerID inner join OrderDetails on OrderDetails.orderID = Orders.orderID;
23.
Select * from products where reorderlevel = 0 and discontinued = 'F';
24.
Select * from Customers,Orders where Customers.customerID = Orders.customerID and year(orderDate) = 1996;
25.
Select * from Customers,Orders where Customers.customerID != Orders.customerID and year(orderDate) = 1996;
Do ask if any doubt. Please up-vote.
Questions are based on the Northwind database. a. A data dictionary (Excel file) that describes each...
The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. Here is the schema of the database: Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued); Suppliers (SupplierID, CompanyName, ContactName , ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage); Categories (CategoryID, CategoryName, Description, Picture); Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName,ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry); Order_details (ID, OrderID,...
Question for SQL in MS SQL Server Management Studio (Please
don't use where clause for Joins use from clause)
Need to Create a Query to display products purchased by
customers in Germany that were not purchased by customers in the
US.
Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode Country Phone char(5) varchar(40) varchar(30) varchar(30) varchar(60) varchar(15) varchar(15) varchar(10) varchar(15) varchar(24) varchar(24) Order Details Orders PK OrderID int FK CustomerlD char(5) FK Employeeld int...
Question for SQL in MS SQL Server Management Studio (Please
don't use where clause for Joins use from clause)
Need to Create a Query because Northwind Traders wants to make
sure that all orders are shipped within 10 days. Display any orders
that were not shipped within 10 days. Include the OrderID, the
OrderDate, and the number of days it took before the order was
shipped.
Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode...
Question for SQL in MS SQL Server Management Studio (Please
don't use where clause for Joins use from clause)
Need to Create a Query because Northwind Traders has decided to
increase their retail prices. Write a query that shows the product
name, the current price, and the new price. Make sure the new price
is listed to 2 decimal points. Follow below guidelines on new
retail price:
a. If the
category is beverages or dairy products, increase the price by...
Create the following SQL Server queries that access the
Northwind database
Same as problem 3 but, limit the list to all customers who
placed 3 or more orders.
The product id, product name, last date that the product was
ordered for all items in the Grains/Cereals category. (Hint: Use
MAX)
The product ID, product name, and number of distinct customers
who ordered that product in 1996
Thank you.
Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...
Display all customers. If a customer has placed any orders, also
display the highest.....
Tables:
CREATE TABLE Sales.Customers
(
CustomerId
INT
NOT NULL
IDENTITY,
CustomerName
NVARCHAR(50)
NOT NULL,
StreetAddress NVARCHAR(50) NULL,
City
NVARCHAR(20)
NULL,
[State]
NVARCHAR(20)
NULL,
PostalCode
NVARCHAR(10)
NULL,
Country
NVARCHAR(20)
NULL,
Contact
NVARCHAR(50)
NULL,
Email
NVARCHAR(50)
NULL,
CONSTRAINT PK_Customers PRIMARY KEY(CustomerId)
);
CREATE TABLE HR.Employees
(
EmployeeId
INT
NOT NULL
IDENTITY,
FirstName
NVARCHAR(50) NOT
NULL,
LastName
NVARCHAR(50)
NOT NULL,
BirthDate DATE
NOT NULL,
HireDate
DATE
NOT NULL,
HomeAddress...
Write a query that lists the top 3 suppliers ordered by their
contact name in descending order
Write a query that list all the countries that start with the
litter M. Make sure you don’t have any duplicates.
List all product Name and unit price. Order the result by the
unit price un descending order
Customer > Customer int <p FirstName nvarchar(40) LastName nvarchar(40) City nvarchar(40) Country nvarchar(40) Phone nvarchar(20) 8 IndexCustomerName Supplier Supplier int spk Order Order int <pk>...
can someone solve these quick
please and thank you!
sql chapter 4
Query #1: List the company name, contact name, contact title and
the phone number for customers who HAVE NOT put in an order. Use an
outer join.
Query #2: Create a listing displaying the employee first name,
last name and the full name (First name space Last Name) of the
person they report to (Supervisor). This is a self-join. If an
employee does not report to anyone then...
Based on the CREATE TABLE
statements, make an ER model of the database. Give suitable names
to the relationships. (Remember cardinality and participation
constraints.) The diagram must use either the notation used in the
textbook (and the lectures) or the crow’s foot notation. To save
you some time: There are a few tables that include the following
address fields: Address, City, State, Country and PostalCode (and
the same fields with the prefix Billing-). You are allowed to
replace these attributes...
Excel file Homework1 - invoices.xlsx contains data
about invoices of a reseller of office equipment that ships its
products to customers in several countries. The tables in the
workbook refer to data collected from different systems within the
company.
a) Copy worksheet “InvoiceHeader” into a new worksheet. For each
invoice in the new worksheet, show the matching information from
the other tables: Invoice date, Invoice Number, Customer ID,
Customer Name, Country, Invoice Quantity, Unit Cost, Unit
Price.
b) In the...