SQLTeam.com | Weblogs | Forums

Beginner SQL Homework Help!

I'm using this W3Schools SQL Editor to enter my commands for my intro class. For the life of me I can't get the extended price. Here is my homework:

  • Select order number, order date, product name, quantity ordered, and extended price (quantity * price) for all customers (INNER JOIN, AS, calculated field).

  • Select order number, order date, product name, quantity ordered, and extended price for customer 2 (INNER JOIN, AS, calculated field, WHERE).

  • Select order number, order date, product name, quantity ordered, and extended price for customer 'Around the Horn' (INNER JOIN, AS, calculated field, WHERE).

  • Add a new shipper with ID 4, name 'On Time Delivery', and phone '(503) 555 0123' (INSERT).
  • Increase prices on all products by 1 (UPDATE).
  • Reduce prices on all products by 1 (UPDATE).
  • Change the new shipper's name from 'On Time Delivery' to 'On-Time Delivery' (UPDATE, WHERE).
  • Delete the new shipper (DELETE, WHERE).

I appreciate you being honest about this being your homework. what have you tried?

I tried
SELECT OrderDetails.ProductID as ProductName, OrderDetails.Quantity, Orders.OrderID AS OrderNumber, Orders.OrderDate, Products.Price
FROM ((OrderDetails
INNER JOIN Orders ON OrderDetails.OrderID = Orders.OrderID)
INNER JOIN Products ON OrderDetails.PriceID = Products.Price);

But I'm getting the error "No value given for one or more required parameters". How can I join Products so I can get the price and multiply it by quantity?

Remove all of the parenthesis

Still doesn't work. :frowning:

hi

Maybe you are joining on the wrong column !!

Here's your SQL formatted !!! ( Try this )

SELECT
    OrderDetails.ProductID AS ProductName
    , OrderDetails.Quantity
    , Orders.OrderID AS OrderNumber
    , Orders.OrderDate
    , Products.Price
FROM OrderDetails
      INNER JOIN Orders
          ON OrderDetails.OrderID = Orders.OrderID
     INNER JOIN Products
         ON OrderDetails.PriceID = Products.Price

I got the error, "Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'".

hi

OrderDetails table does not have any column ..PriceID

INNER JOIN Products
ON OrderDetails.PriceID = Products.Price

1 Like

PriceId to Price?

Change join on Products to use ProductID instead of price

SELECT OrderDetails.ProductID AS ProductName
    , OrderDetails.Quantity
    , Orders.OrderID AS OrderNumber
    , Orders.OrderDate
    , Products.Price
FROM OrderDetails
      INNER JOIN Orders
          ON OrderDetails.OrderID = Orders.OrderID
     INNER JOIN Products
         ON OrderDetails.ProductID = Products.ProductID

send us a link to this course? and what db product is this for? Microsoft SQL Server?

It's for a intro to web fundamentals class and this week is on databases. So I'm brand new to SQL. We had to complete 20 activities/SQL commands. The remaining ones I had left were the ones I posted. We're just using it from W3schools SQL tutorial.

I appreciate all your help so far!!!