Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Normalization and SQL Join Need sql for: Display all customer. If a customer has placed any orders, also display the highest unit price in any

Normalization and SQL Join

Need sql for:

Display all customer. If a customer has placed any orders, also display the highest unit price in any order of the customer. Otherwise, display null. We want to know each customers highest price item ever ordered. Show customerId, customerName, and the highest unit price in any order of that customer

CustomerID

CustomerName

Highest Unit Price

1

Just Electronics

1599.99

2

Beyond Electronics

1449.99

3

Beyond Electronics

1499.99

4

E Fun

99.99

5

Overstock E

999.99

6

E Fun

NULL

7

Electronics4U

79.99

8

Cheap Electronics

NULL

My sql is not correct

Select CustomerID, CustomerName, Max(Price) AS "Highest Unit Price"

FROM Sales.Customers JOIN Sales.Orders

ON Sales.CustomerID = Sales.CustomerID

RIGHT JOIN Sales.OrderDetail

ON Sales.CustomerId = Sales.CustomerID

Group BY OrderID

image text in transcribed

Sales.customers Columns Customerld (PK, int, not null) CustomerName (nvarchar(50) StreetAddress (nvarchar(50), n City (nvarchar(20), null) State (nvarchar(20), null) B PostalCode (nvarchar(10), nul Country (nvarchar(20), null) Contact (nvarchar(50), nul) Email (nvarchar(50), null) DKeys Constraints Triggers Indexes Statistics Sales.OrderDetails Columns Orderld (PK, FK, int, not null) Productld (PK, FK, int, not nul) Price (money, not null) Equantity (smallint, not null) Keys Constraints Triggers Indexes Statistics

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Why could the Robert Bosch approach make sense to the company?

Answered: 1 week ago