• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finiding the maximum value in a relation

 
Dan Czarnecki
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again.

I have another little query that I need help with.

The following is the schema of the tables that I will be referencing data from:
orders(orderNumber, orderDate, requiredDate, shippedDate, status, comments, customerNumber)
orderdetails(orderNumber, productCode, quantityOrdered, priceEach, orderLineNumber)
customers(customerNumber, customerName, contactFirstName, contactLastName, phone, addressLine1, addressLine2, city, state, postalCode, country, salesRepEmployeeNumber, creditLimit)

Here is the question that I need some help with:
What customer(s) has made the largest order in terms of dollars (Note: that an order can consist of multiple line items and each line item has a quantity)?

Here's what I've done so far


Am I on the right track so far?
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, no. For one thing the question asks about the dollar amount of orders but I don't see you calculating dollar amounts (quantityOrdered * priceEach) anywhere. And it seems to me you should be adding up the dollar amounts of all an order's line items to get the dollar amount of the order, and I don't see you doing that either.
 
Dan Czarnecki
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Sorry, no. For one thing the question asks about the dollar amount of orders but I don't see you calculating dollar amounts (quantityOrdered * priceEach) anywhere. And it seems to me you should be adding up the dollar amounts of all an order's line items to get the dollar amount of the order, and I don't see you doing that either.


Yeah, that's what I figured. I actually got someone I know to help me out with its problem before, but thanks for the response back anyway.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When people get an assignment, they almost start coding right away. But that's often not the right approach, it's sometimes much better to turn off your computer and take a pencil and a paper and start writing down the steps required to solve the problem without using a computer. Once you have listed these steps, you can start converting them into SQL.

That's also the reason why I split your other problem into two smaller problems which would be easier to solve. Here at CodeRanch we are willing to help and give you advice if you are stuck with an issue, but we are NotACodeMill and you should definitely DoYourOwnHomework and ShowSomeEffort.

Here's a nice quote which illustrates perfectly what we are trying to do here at CodeRanch: Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic