Question

SQL commands of following questions: 4.List the count of orders and the nation name in each...

SQL commands of following questions:

4.List the count of orders and the nation name in each nation (join three tables: orders, customer and nation, and then use count(*) and group by)

5. List the sum of the total price and the nation name in each nation, descending by the sum of the total price. (join three tables and then use group by, order by and sum())

0 0
Add a comment Improve this question Transcribed image text
Answer #1
List the count of orders and the nation name in each nation (join three tables: orders, customer and nation, and then use count(*) and group by)
  1. SELECT COUNT(O.Orderid), N.NationName
  2. FROM [Order] O JOIN Customer C
  3. ON O.OrderId = C.CustomerId
  4. JOIN Nation N ON N.id=C.Id
  5. GROUP BY N.NationName

List the sum of the total price and the nation name in each nation, descending by the sum of the total price. (join three tables and then use group by, order by and sum())

  1. SELECT SUM(O.TotalPrice), N.NationName
  2. FROM [Order] O JOIN Customer C
  3. ON O.OrderId = C.CustomerId
  4. JOIN Nation N ON N.id=C.Id
  5. GROUP BY N.NationName
  6. ORDER BY SUM(O.TotalPrice) DESC
Add a comment
Know the answer?
Add Answer to:
SQL commands of following questions: 4.List the count of orders and the nation name in each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #6 Write a SELECT statement that returns these columns: The count of the number of orders...

    #6 Write a SELECT statement that returns these columns: The count of the number of orders in the Orders table The sum of the tax_amount columns in the Orders table Write a SELECT statement that returns one row for each category that has products with these columns: The category_name column from the Categories table The count of the products in the Products table The list price of the most expensive product in the Products table Sort the result set so...

  • I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental...

    I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental ID, Rental date, customer ID, customer first name, customer last name, and count of disks rented; sort by Rental ID. Show the Rental date formatted as ‘mm-dd-yyyy.’ Hint: use a GROUP BY clause. 19. 4 points List the disk ID, title name, rating, format description, and fee amount for all copies rented in Rental 3; sort by disk ID. Show the fee amount formatted...

  • 2) What were the total rental fees for each member by member last name? (w3schools-> SQL...

    2) What were the total rental fees for each member by member last name? (w3schools-> SQL Inner Join& SQL Functions Count, Avg, Sum & SOL Group By)- this requires 2 joins 13) What were the total rental fees for members treport Mem num who total fees were greater than $5-change the output label to FeesMoreThan5S? (w3schools->SQL Inner Join & SQL Functions Count, Avg, Sum& SQL Group By & SQL Having) 14) What was the highest fee paid by each member...

  • pls help me with these SQL questions Here are tables TEAM table Task 10 (4 marks)...

    pls help me with these SQL questions Here are tables TEAM table Task 10 (4 marks) Write an SQL statement to display fan categories, the number of tickets in each category the fan bought (change the alias to "NUMBER OF TICKETS PURCHASED") along with the sum of prices (change the alias to TOTAL PRICES') in each category the fans paid. Sort the result by total price in an ascending order. Task 11 (5 marks) Write an SQL statement to display...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    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...

  • Scenario: Elite Video is a startup company providing concierge DVD kiosk service in Kennesaw, GA. FIGURE...

    Scenario: Elite Video is a startup company providing concierge DVD kiosk service in Kennesaw, GA. FIGURE P8.47 THE CH08 MOVIECO ERD DETAILRENTAL MEMBERSHIP RENTAL PK MEM NUM PK,FK1 RENT NUM PK,FK2 VID NUM PK RENT NUM RENT DATE FK1 MEM_NUM MEM_FNAME MEM_LNAME MEM_STREET MEM_CITY MEM_STATE MEM_ZIP MEM_BALANCE DETAIL_FEE DETAIL_DUEDATE DETAIL_RETURNDATE DETAIL_DAILYLATEFEE MOVIE VIDEO PK MOVIE NUM PK VID NUM PRICE -0% PK PRICE CODE VID_INDATE FK1 MOVIE_NUM PRICE DESCRIPTION PRICE_RENTFEE PRICE_DAILYLATEFEE MOVIE_TITLE 0---06 MOVIE YEAR MOVIE_COST MOVIE GENRE FK1 PRICE_CODE...

  • Using the following tables write a sql command: List the full name and the total number...

    Using the following tables write a sql command: List the full name and the total number of transactions handled by the full time employee. Rank your results in descending order on the total number of transactions. Table: MEMBERS Column Data Type Length Precision Scale Nullable MEMBERID NUMBER 4 0 No MFIRST VARCHAR2 25 No MLAST VARCHAR2 25 No STREET VARCHAR2 64 No CITY VARCHAR2 25 . No STATE VARCHAR2 2 . No ZIPCODE NUMBER 0 No CREDITLIMIT NUMBER 7 2...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • The category name and a count of the number of products within each category. The listing...

    The category name and a count of the number of products within each category. The listing should be sorted by category name. A listing of the customer name, last name of employee who accepted the order, and the shipper for all orders from customers based in North America and shipped through either United Package or Federal Shipping. The listed must be sorted alphabetically by customer name. Please use https://www.w3schools.com/sql/

  • Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number...

    Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number of Books published by each publisher. 2. List Publisher ID, Publisher Name, Title and price of the highest priced book. 3. List Order ID, Customer ID, Order Date, and Number of Items in each order. Order the data by Customer ID in ascending (A – Z) order. 4. Display Title, Category and Profit for each book in the children and computer category. 5. Display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT