Question

I need to create a SQL query that displays the names of the customers who purchased...

I need to create a SQL query that displays the names of the customers who purchased the book with the highest retail price in the database. Also I need to capitalize the first and last names.

CUSTOMERS Table:

CUSTOMER#, LASTNAME, FIRSTNAME, ADDRESS, CITY, STATE, ZIP, REFERRED, REGION, EMAIL

ORDERS Table:

ORDER#, CUSTOMER#, ORDERDATE, SHIPDATE, SHIPSTREET, SHIPCITY, SHIPSTATE, SHIPZIP, SHIPCOST

ORDERITEMS Table:

ORDER#, ITEM#, ISBN, QUANTITY, PAIDEACH

0 0
Add a comment Improve this question Transcribed image text
Answer #1

-- initlai letter cap INITCaP function in oracle

Select c.Customer#,INITCAP(c.lastame) AS LastName,INITCAP(c.firstname),Max(ol.paideach) as MaxRetail
from customers c inne join orders o on c.customer#=o.customer# inner join orderitems ol on o.order#=ol.order#

--Initial Letter cap in Sql server
Select c.Customer#,
UPPER(LEFT(c.lastame,1))+LOWER(SUBSTRING(c.lastame,2,LEN(c.lastame))) As LastName,
UPPER(LEFT(c.firstname,1))+LOWER(SUBSTRING(c.firstname,2,LEN(c.firstname))) As firstname,
Max(ol.paideach) as MaxRetail
from customers c inne join orders o on c.customer#=o.customer# inner join orderitems ol on o.order#=ol.order#

Add a comment
Know the answer?
Add Answer to:
I need to create a SQL query that displays the names of the customers who purchased...
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
  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • I accidentally selected an answer which I don't know if it's correct or not Question 13...

    I accidentally selected an answer which I don't know if it's correct or not Question 13 1 pts Structure of the ORDERS table + Oracle SQL Plus File Edit Search Options Nane Help Null? Type ORDERE CUSTOMER ORDERDATE SHIPDATE SHIPSTREET SHIPCITY SHIPSTATE SHIPZIP NOT NULL NUMBER (4) NUMBER (4) DATE DATE VARCHAR2(18) VARCHAR2(15) VARCHAR2(2) VARCHAR2(5) Based upon the structure of the ORDERS table, which of the following is a valid SQL statement? O SELECT "order#", "customer#" FROM orders; SELECT order#,...

  • Write a SQL query that shows the price of each order made by customers whose last name starts wit...

    Write a SQL query that shows the price of each order made by customers whose last name starts with the letter M. Display the order number, the last name on the order, and the price of the order (Order Price). Show the results with the highest order price first. Write a SQL query that determines the most expensive item purchased in each order (Item Price). Display the order number, the date of the order, the last name of the customer...

  • Create an SQL Query to show how many customers there are in each state. Sample results ST CUST_C...

    Create an SQL Query to show how many customers there are in each state. Sample results ST CUST_COUNT -- ---------- CA          1 GA          1 CO          2 DC          1 WA          4 BC          1 CUSTOMER CustomerlD ARTIST TRANS WORK SArtistID LastName PURCHASES/SOLD TO Q TransactionID ACQUIRED OworkID CREATES/CREATEDBY FirstName AreaCode LocalNumber Street City State ZipPostalCode Country Email (AK1.1) DateAcquired AcquisitionPrice DateSold SalesPrice AskingPrice WorkID (FK) CustomerlD (FK) Title (AK1.1) o- Copy (AK1.2) Medium Description ArtistID (FK) LastName (AK1.1) FirstName (AK1.1) Nationality DateOfBirth...

  • NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...

    NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR FOREIGN etc Customer [ CustID, LastName, FirstName, Address, City, State, Zip, Phone, Fax, Email] Product [ ProdID, Description, Color, Size, Pack] Sales [ TransID, CustID, ProdID, Price, Quantity, Amount] Write SQL statement to produce a list of unique products and their prices from the Sales table. Please ensure that the products do not repeat. Write an SQL statement to list ProdID and Description for...

  • Can you look and see where I could improve on this ERD and ensure that the...

    Can you look and see where I could improve on this ERD and ensure that the ERD is correct? For this task, you are to normalize the ERD that has been developed to remove any partial dependencies or transitive dependencies that may exist. Two things about customers to consider when modifying your ERD are that customers may have more than one shipping address and multiple credit cards they can use to pay for their order. Also, there are several shipping...

  • Chapter 2 How to use the Management Studio Before you start the exercises... Before you start...

    Chapter 2 How to use the Management Studio Before you start the exercises... Before you start these exercises, you need to install SQL Server and the SQL Server Management Studio. The procedures for doing both of these tasks are provided in appendix A of the book. In addition, you'll need to get the Exercise Starts directory from your instructor. This directory contains some script files that you need to do these exercises. Exercises In these exercises, you'll use SQL Server...

  • List the names of the customer (or customers) who spent the greatest dollar amount in a single order.please give me an sql query for this question and i have tables as follows customer(customer_name,a...

    List the names of the customer (or customers) who spent the greatest dollar amount in a single order.please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)

  • List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(...

    List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)

  • SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh...

    SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh your memory – here is the schema for that database: Create the rest of the contact management database by writing the statements that do each of the following items below. For each one: (1) execute them on your copy of the database, and (2) write the statements in the space: Statement to create the Contact table (one statement) Statement to create the Employee table...

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