Question

1. Using a function, display the customer who has the highest credit limit. Display the customer...

1. Using a function, display the customer who has the highest credit limit. Display the customer

number, customer name, and credit limit. Insert your snip of the query and resultset together

here:

2. How many customers have the same credit limit? Display the count of customers by credit

limit. Display the count as ‘Number of Customers’ and credit limit as ‘Credit Limit’. Insert your

snip of the query and resultset together here:

3. What is the average quoted price, maximum quoted price, and minimum quoted price of all

orders? Display the average as ‘Average Quoted Price’, maximum quoted price as ‘Maximum

Quoted Price’, and minimum quoted price as ‘Minimum Quoted Price’. Extra decimal places are

okay for now. Insert your snip of the query and resultset together here:

Premier Product database:

#--Project: Premier Products DB script file using create and insert

#-----CREATE AND OPEN THE DATABASE

#-- Creating Databases

CREATE DATABASE premier_products;


#-- Creating Tables

USE premier_products;

#-- Rep Table

CREATE TABLE rep

(

rep_num char(2) primary key,

last_name varchar(15),

first_name varchar(15),

street varchar(15),

city varchar(15),

state char(2),

zip char(5),

commission decimal(7,2),

rate decimal(3,2)

);

#-- Customer table

CREATE TABLE customer

(

customer_num char(3) primary key,

customer_name varchar(30),

street varchar(15),

city varchar(15),

state char(15),

zip char(5),

balance decimal(7,2),

credit_limit decimal(7,2),

rep_num char(2)

);


#-- Orders table

CREATE TABLE orders

(

order_num char(5) primary key,

order_date timestamp,

customer_num char(3)

);


#-- Order_line table

CREATE TABLE order_line

(

order_num char(5),

part_num char(4),

num_ordered int(5),

quoted_price decimal(7,2),

PRIMARY KEY (order_num, part_num)

);

#-- Part table


CREATE TABLE part

(

part_num char(4) primary key,

description varchar(20),

on_hand int(4),

class char(2),

warehouse char(2),

price decimal (7,2)
);


#-- Populate rep table

INSERT INTO rep values ('20', 'Kaiser', 'Valerie', '624 Randall', 'Grove', 'FL', '33321', 20542.50, 0.05);

INSERT INTO rep values ('35', 'Hull', 'Richard', '532 Jackson', 'Sheldon', 'FL', '33553', 39216.00, 0.07);

INSERT INTO rep values ('65', 'Perez', 'Juan', '1626 Taylor', 'Fillmore', 'FL', '33336', 23487.00, 0.05);


#-- Populate customer table

INSERT INTO customer values ('148', 'Al''s Appliance and Sport', '2837 Greenway', 'Fillmore', 'FL', '33336',
6550.00, 7500.00, '20');

INSERT INTO customer values ('282', 'Brookings Direct', '3827 Devon', 'Grove', 'FL', '33321', 431.50, 10000.00, '35');

INSERT INTO customer values ('356', 'Ferguson''s', '382 Wildwood', 'Northfield', 'FL', '33146', 5785.00, 7500.00,
'65');

INSERT INTO customer values ('408', 'The Everything Shop', '1828 Raven', 'Crystal', 'FL', '33503', 5285.25, 5000.00, '35');

INSERT INTO customer values ('462', 'Bargains Galore', '3829 Central', 'Grove', 'FL', '33321', 3412.00, 10000.00, '65');

INSERT INTO customer values ('524', 'Kline''s', '838 Ridgeland', 'Fillmore', 'FL', '33336', 12762.00, 15000.00, '20');

INSERT INTO customer values ('608', 'Johnson''s Department Store', '372 Oxford', 'Sheldon', 'FL', '33553', 2106.00, 10000.00, '65');

INSERT INTO customer values ('687', 'Lee''s Sport and Appliance', '282 Evergreen', 'Altonville', 'FL', '32543', 2851.00, 5000.00, '35');

INSERT INTO customer values ('725', 'Deerfield''s Four Seasons', '282 Columbia', 'Sheldon', 'FL', '33553', 248.00, 7500.00, '35');

INSERT INTO customer values ('842', 'All Season', '28 Lakeview', 'Grove', 'FL', '33321', 8221.00, 7500.00, '20');

#-- Populate orders table

INSERT INTO orders value ('21608', '2015-10-20', '148');

INSERT INTO orders value ('21610', '2015-10-20', '356');
INSERT INTO orders value ('21613', '2015-10-21', '408');

INSERT INTO orders value ('21614', '2015-10-21', '282');

INSERT INTO orders value ('21617', '2015-10-23', '608');
INSERT INTO orders value ('21619', '2015-10-23', '148');

INSERT INTO orders value ('21623', '2015-10-23', '608');


#-- Populate order_line table

INSERT INTO order_line value ('21608', 'AT94', 11, 21.95);

INSERT INTO order_line value ('21610', 'DR93', 1, 495.00);

INSERT INTO order_line value ('21610', 'DW11', 1, 399.99);

INSERT INTO order_line value ('21613', 'KL62', 4, 329.95);

INSERT INTO order_line value ('21614', 'KT03', 2, 595.00);

INSERT INTO order_line value ('21617', 'BV06', 2, 794.95);

INSERT INTO order_line value ('21617', 'CD52', 4, 150.00);

INSERT INTO order_line value ('21619', 'DR93', 1, 495.00);

INSERT INTO order_line value ('21623', 'KV29', 2, 1290.00);


#--Populate part table

INSERT INTO part value ('AT94', 'Iron', 50, 'HW', '3', 24.95);

INSERT INTO part value ('BV06', 'Home Gym', 45, 'SG', '2', 794.95);

INSERT INTO part value ('CD52', 'Microwave Oven', 32, 'AP', '1', 165.00);

INSERT INTO part value ('DL71', 'Cordless Drill', 21, 'HW', '3', 129.95);

INSERT INTO part value ('DR93', 'Gas Range', 8, 'AP', '2', 495.00);

INSERT INTO part value ('DW11', 'Washer', 12, 'AP', '3', 399.99);

INSERT INTO part value ('FD21', 'Stand Mixer', 22, 'HW', '3', 159.95);

INSERT INTO part value ('KL62', 'Dryer', 12, 'AP', '1', 349.95);

INSERT INTO part value ('KT03', 'Dishwasher', 8, 'AP', '3', 595.00);

INSERT INTO part value ('KV29', 'Treadmill', 9, 'SG', '2', 1390.00);

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

NOTE: Small correction in table creation, We should not declare integer type attributes as int(4) - it should just be int

1.

select customer_num , customer_name , credit_limit
from customer
where credit_limit = (select max(credit_limit) from customer);

ResultSet:

2.

select count(customer_num) as "Number of Customers" , credit_limit as "Credit Limit"
from customer
group by credit_limit;

3.


select avg(quoted_price) as "Average Quoted Price " , min(quoted_price) as "Minimum Quoted Price ", max(quoted_price) as "Maximum Quoted Price" from order_line;

ResultSet:

Add a comment
Know the answer?
Add Answer to:
1. Using a function, display the customer who has the highest credit limit. Display the 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
  • 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...

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

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

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

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

  • 2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures...

    2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures listed below.   Test2SP1 Test2SP2 Test2SP3 Test2SP4 Test2SP5 Test2SP6 DATABASE CODE: if db_id('Test2PremierProducts') is not null begin use master alter database Test2PremierProducts set SINGLE_USER with rollback immediate drop database Test2PremierProducts end create database Test2PremierProducts go USE Test2PremierProducts; go /* create the tables */ CREATE TABLE Rep (RepNum int Identity(10,10), LastName VARCHAR(15), FirstName VARCHAR(15), Street VARCHAR(15), City VARCHAR(15), State VARCHAR(2), Zip VARCHAR(5), Commission MONEY, Rate DECIMAL(3,2),...

  • --Create procedure for GetPartNums in SQL --GetPartNums- retrieve all part nums from the database --Database if...

    --Create procedure for GetPartNums in SQL --GetPartNums- retrieve all part nums from the database --Database if db_id('TestPremierProducts') is not null begin use master alter database TestPremierProducts set SINGLE_USER with rollback immediate drop database TestPremierProducts end create database TestPremierProducts go USE TestPremierProducts; go /* create the tables */ CREATE TABLE Rep (RepNum int Identity(1,1), LastName VARCHAR(15), FirstName VARCHAR(15), Street VARCHAR(15), City VARCHAR(15), State VARCHAR(2), Zip VARCHAR(5), Commission MONEY, Rate DECIMAL(3,2), PRIMARY KEY (RepNum)); go CREATE TABLE Customer (CustomerNum int Identity(1,1) PRIMARY...

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

  • Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice...

    Using the ch08_saleco database write a T-SQL query to display the customer code, invoice number invoice date, and invoice subtotal from invoice conditioned on the invoice subtotal is greater than $100 and from only customer codes 10011 and 10012. (hint: in) /* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER ( CUS_CODE int, CUS_LNAME varchar(15), CUS_FNAME varchar(15), CUS_INITIAL varchar(1), CUS_AREACODE varchar(3), CUS_PHONE varchar(8), CUS_BALANCE float(8) ); INSERT INTO CUSTOMER VALUES('10010','Ramas','Alfred','A','615','844-2573','0'); INSERT...

  • True or false? True or false? Question 63 Based on the Customer table below, which command...

    True or false? True or false? Question 63 Based on the Customer table below, which command lists all information from the table concerning customer 282? CustomerNum CustomerName --- Street City State Zip 148 Al's Appliance 28 Greenway Filmore FL 33336 282 Brookings 3827 Devon Grove FL 33321 Question 37 You have your project all set locally and on the server. You want to now make changes to your site. Which of the following is the last step of the process?...

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