Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can my adjust my query so I that I get the expect results instead of the actual results? Original Assignment Question: Using your Northwind

How can my adjust my query so I that I get the expect results instead of the actual results?

Original Assignment Question:

Using your Northwind Postgres database, write a query that reports the maximum sales and the corresponding product from each employee. The output result should contain the following column headers: First Name, Last Name, Product Name, and Sales. The output should be similar to the following output:

image text in transcribed

SQL Code I have written:

select a.First_Name, a.Last_Name, d.Product_Name, MAX ( c.Unit_Price * c.Quantity) Sales

From employees a, orders b, order_details c, products d

where a.Employee_ID= b.Employee_ID

and b.Order_ID = c.Order_ID

and c.Product_ID = d.Product_ID

group by first_name, last_name, product_name

order by a.First_Name asc;

Results in multiple of each Employee:

image text in transcribed

Response to comment - Northwind database table structure

image text in transcribed

Firstname LastName ProductName Cte de Blaye 2Anne Dodsworth Cte de Blaye erling Cte de Blaye 1 Andrew Fuller 25190.5999755859 14624.25 25559.5 3 Janet 4Laura Callahan Thringer Rostbratwurst 9244.82507324219 5 Margaret Peacock Cte de Blaye 6 Michae Suyama Raclette Courdavault 6671.5 7 Nancy volio Cte de Blaye 8 Robert King 9 Steven Buchanan Raclette Courdavault 7584.5 29432.9499511719 23570.0749511719 16695.3603515625 Cte de Blaye Northwind on postgres@PostgreSQL 11 Query Editor Query History 1 select a.First_Name, a. Last_Name, d.Product_Name, MAXc.Unit_Price c.Quantity) Sales 2 From employees a, orders b, order_details c, productsd 3 where a. Employee_ID- b.Employee_ID and b.0rder_IDc.Order_ID and c. Product_IDd.Product_ID group by first_name, last_name, product_name 7 order by a.First_Name asc; Data Output Ex plain Messages Notifications character varying (10) character varying (20) character varying (40) Chef Anton's Cajun Seaso.. Boston Crab Meat Gumbr Gummibrchen Uncle Bob's Organic Dried Thringer Rostbratwurst Manjimup Dried Apples Cte de Blaye Vegie-spread Gula Malacca Mozzarella di Giovanni Sirop d'rable Pt chinois Zaanse koeken Tunnbrcd Chartreuse verte Rhnbru Klosterbier Alice Mutton double precision 550 551.999988555908 746.999988555908 1800 7427.40005493164 2650 15810 561.599975585938 466.800018310547 835.199981689453 2 Andrew 4 Andrew Andrew 6 Andrew 7 Andrew 8 Andrew Andrew 10 Andrew Andrew 12 Andrew 13 Andrew 14 Andrew 15 Andrew 16 Andrew 17 Andrew 2304.00009155273 151.199995994568 1440 232.5 2184.00005340576 Fuller Cauniay

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

Step: 3

blur-text-image

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions