Question

Create sql query command for the following.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • Select customer_name, customer_key,sum(order_amount),count(orders) from customers group by customer_key;

This query retrieves the name, key and the count of orders and the amount for all orders. We have just written the name and key attribute here, then we need the sum of amount so we have written sum function it adds the respective amount in that column and the count function will give the count of orders.

Niw if we simply write this the result will be horrible, here we need to have for every respective customer individually, for that we are using group by Clause it groups according to the given attribute. In this it is customer key we are given. It groups according to the customer key then gives the result.

Add a comment
Know the answer?
Add Answer to:
Create sql query command for the following. Modify your query and produce the following results. Customer...
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
  • More on JOINS Log in to your ApEX SQL account. Two Table Join Create a SQL...

    More on JOINS Log in to your ApEX SQL account. Two Table Join Create a SQL query that gets the order ID, order_mode, customer ID and product ID from the ORDERS and ORDER_ITEMS tables. You will have to join the tables on some common column. Two Table Join With Subquery Modify the previous query and add a subquery that looks for the existence of a customer ID in the CUSTOMERS table. This is a correlated sub-query so you will have...

  • SQL Question: 1:The SCRIPT...AS command in the SSMS will A. Execute a command to create the...

    SQL Question: 1:The SCRIPT...AS command in the SSMS will A. Execute a command to create the object. B. Retrieve the properties of the object. C. Retrieve a data result-set. D. Create a query script of the object. 2:As queries are written, if the IntelliSense is enabled in the SSMS, there will be A. Indents added to the second line. B. Comments automatically added. C. Table and column options. D. New query windows available.

  • For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne...

    For this hands-on project, you will use the SQL Server named instance SQLSERVERHOA, and the HandsOnOne database and tables you created in previous chapters. The objective of this activity is to practice generating keys and encrypting/decrypting data. Document each step by taking a screen shot of the Query Editor window after successfully executing each SQL query. 1.In SQL Server Management Studio, open a new Query Editor window, which you will use for completing all steps in this activity. 2.Create a...

  • Provide the SQL to create a view to retrieve the total number of a particular product...

    Provide the SQL to create a view to retrieve the total number of a particular product a particular customer ordered, the name of that product and the customer ID Hint: You will do this by executing an implict join on Orders and OrderDetails, with a condition for 'OrderDetails.ProductID in (query to retreive product)' and will use the sum() function

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

  • 2. SQL queries (40 points total, 5 points each query) Write SQL query statements to query...

    2. SQL queries (40 points total, 5 points each query) Write SQL query statements to query the following Hotel Room Booking Database Tables. "cid" is Customer ID. "rid" is Room ID. "bid" is Booking ID. "dob" means Date of Vwwww Birth; "beds" means the number of beds in the room which is normally 1 or 2 beds. "DueDate" and "DueAmount" are the payment due dates and due amounts of this booking. Customers fname name phone email cid dob zipcode Rooms...

  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • I need help in SQL management studio please. Question: Create the same query as query 5,...

    I need help in SQL management studio please. Question: Create the same query as query 5, but only include artists if they have 'Pop' Genre. Previous question: Create a list of all composers and artists in your database. Include two columns in your record set (the names of the returned columns are in brackets): 'Composer/Artist Name' and 'Type' (which will indicate whether your results are from the composer or artist table). Order by 'Composer/Artist Name'. This is the answer for...

  • SQL Command - Create a view called S LIST that lists the Cardholder Number, last name,...

    SQL Command - Create a view called S LIST that lists the Cardholder Number, last name, first name and due date for all cardholders who have not returned a book. Use the CREATE OR REPLACE VIEW AS ... command. TABLE CARD HOLDERS Cardholder Numberint NOT NULL CONSTRAINT CH PK PRIMARY KEY, First_Name varchar(10) NULL, LastName varchar(15) NULL, Address varchar(20) NULL, varchar(15) NULL, State char(2) NULL, Zip_Code char(5) NULL) City TABLE BOOKS CHECKED OUT Cardholder_Numberint NOT NULL, Book Numberint NOT NULL,...

  • SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer...

    SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer last name. Order the results by customer last name. 2. For each reservation for customer Ryan Goff, list the reservation ID, trip ID, and number of persons. 3. List the trip name of each trip that has Miles Abrams as a guide. 4. List the trip name of each trip that has the type Biking and that has Rita Boyers as a guide. 5....

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