Question

Ecustomer E Columns IB New balance I city D| credit_limit 4 customer_name customer_num rep_num Dstate street zip Indexes ordeOpart E Columns I New class description 4on_hand l part_num price warehouse Indexes rep EHColumns 4 New city commision first_

Please answer each question using these tables above, it is SQL

  1. Display the descriptions and prices of the 5 most expensive parts, in descending order by price.
  2. For each part, display the On Hand Value, which is calculated by multiplying the quantity on hand by price.
  3. Display a summary with part number, description, on hand and warehouse for all parts in class HW or AP, and in warehouse 1 or 2.
  4. Display the names of customers who do NOT live in the cities of Sheldon, Grove, or Fillmore.
  5. Display all of the cities in which customers live, omitting duplicates.
  6. Display the names of customers that do not have a zip code that starts with 33.
Ecustomer E Columns IB New balance I city D| credit_limit 4 customer_name customer_num rep_num Dstate street zip Indexes orders HColumns INew customer_num I| order_date | order_num Indexes order_line EHHColumns IB New num_ordered order_num part_num 4I quoted_price
Opart E Columns I New class description 4on_hand l part_num price warehouse Indexes rep EHColumns 4 New city commision first_name last_name rate rep_num state street zip
0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. Display the descriptions and prices of the 5 most expensive parts, in descending order by price.

SELECT Top 5 description, price FROM part ORDER BY price DESC;

Explaination: Top will fetch top 5 from the list and we are ordering the list by price in descending order.

  1. For each part, display the On Hand Value, which is calculated by multiplying the quantity on hand by price.

SELECT on_hand * price as on_hand from part;

Exp: We can use * to multiply two columns and rename that column as on_hand.

  1. Display a summary with part number, description, on hand and warehouse for all parts in class HW or AP, and in warehouse 1 or 2.

Select part_num, description, on_hand, warehouse where class in ('HW','AP') and warehouse in (1,2);

Exp: IN function is used to check if the element is present in the given set.

  1. Display the names of customers who do NOT live in the cities of Sheldon, Grove, or Fillmore.

Select customer_name from customer where city NOT IN ('Sheldon', 'Grove', 'Fillmore')

Exp: NOT IN is reverse of IN clause.

  1. Display all of the cities in which customers live, omitting duplicates.

Select Distinct(city) from customer;

Exp: Distinct is used to omit duplicates.

  1. Display the names of customers that do not have a zip code that starts with 33.

Select customer_name from customer where zip like '33%'

Exp: LIKE is used as regular expression and % is used as all the characters. Here I have used '33%' which means match with expression that starts with 33.

Regards.

Add a comment
Know the answer?
Add Answer to:
Please answer each question using these tables above, it is SQL Display the descriptions and prices of the 5 most expe...
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
  • Program: MYSQL (please show screenshots of the solution)  Ill give good rating! Define a view named TopLevelCust...

    Program: MYSQL (please show screenshots of the solution)  Ill give good rating! Define a view named TopLevelCust that consists of the number, name, address, balance and credit limit of all customers with credit limits that are greater than or equal to $5,000. Address is defined as street, city, state and zip. Concatenate these into one field named Address.   A. Type in your view construct here: B. Write a query to retrieve the number and name of all customers in the TopLevelCust...

  • Using the Premier Products database answer the following questions 1. Using a union, display all customers...

    Using the Premier Products database answer the following questions 1. Using a union, display all customers that have rep number 65 or live in the town of Sheldon. Display all customer information. Insert your snip of the query and resultset together here: 2. Using a subquery, list the rep information for all customers who have the same credit limit as customer number 725. To receive credit for this question, do not explicitly query for rep number 35. Let MySQL do...

  • 8.Write the commands to obtain the following information from the systems catalog. List every table that...

    8.Write the commands to obtain the following information from the systems catalog. List every table that you own, list every column in the PART table and its associated data type, then add ORDER_NUM as a foreign key in the ORDER_LINE table. this is the SQL for the database: CREATE DATABASE PREMIERE; USE PREMIERE; CREATE TABLE REP (REP_NUM CHAR(2) PRIMARY KEY, LAST_NAME CHAR(15), FIRST_NAME CHAR(15), STREET CHAR(15), CITY CHAR(15), STATE CHAR(2), ZIP CHAR(5), COMMISSION DECIMAL(7,2), RATE DECIMAL(3,2) ); CREATE TABLE CUSTOMER...

  • Answer the following questions using mysql. Please show screenshots to make sure the queries work...

    Answer the following questions using mysql. Please show screenshots to make sure the queries work. 1. Use a sub-query and the IN operator to find the number and name of each customer that placed an order on October 23, 2007. 2. Repeat step 2, but this time use the EXISTS operator in your answer. 3. Using a sub-query, find the number and name of each customer that did not place an order on October 23, 2007. 4. Using a sub-query,...

  • Use the Premiere Products database (see Figure 1-2 in Chapter 1) to complete the following exercises....

    Use the Premiere Products database (see Figure 1-2 in Chapter 1) to complete the following exercises. If directed to do so by your instructor, use the information provided with the Chapter 3 Exercises to print your output. 1. List the part number and description for all parts. The part descriptions should appear in uppercase letters. 2. List the customer number and name for all customers located in the city of Grove.Your query should ignore case. For example, a customer with...

  • Using MySQL commands answer the questions listed below using the Premier Products Company schema. 1.Using Views...

    Using MySQL commands answer the questions listed below using the Premier Products Company schema. 1.Using Views a) Create a view called part_location that has the following attributes: part_num, part_description, part_quantity, warehouse_name, warehouse_address. This data comes from the part and warehouse entities. b) Write a query using the view that shows the total number of parts ordered from each warehouse. The output should look like this: 2. Using Triggers a) Execute the following SQL to create the customer_audit table in the...

  • The common requirements of all questions are the same. Read each question carefully and submit a...

    The common requirements of all questions are the same. Read each question carefully and submit a query to fulfill for each question. Also, students need to submit the result of the corresponding query under the query. Also, assignment has to be written with Microsoft Word for feedback. For technical issue, other formats, such as image, sql, are not appropriate to receive feedback and comments. Don’t delete or change questions. For assignment 5 and 6, you don’t need to submit screenshots....

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