Vous êtes sur la page 1sur 11

June 3, 2015

SQL
REPORTS
Thomas Randazzo

MIS 370

Page | 1
Report #1: Shows the clients that are not under contract.

Report #2: Shows all clients under contract in the year 2015

Page | 2
Report #3: Shows the average price for contracts

Report #4: Shows how many clients and consultants there are in each region.

Page | 3

Report #5: Shows how many consultants are associated with a class.

Report #6: Shows how many advanced or beginner classes the company has.

Page | 4

Report #7: Shows the average price a consultant charges

Report #8: Shows clients with the last contract end date 5 years or less than 2015.

Page | 5

Report #9: Shows how many classes are at the same time

Report #10: Shows the total sum that each region makes.

Page | 6

Relational Schema
CLASS (Class_Num, Class_Name, Class_Description)
Consultant (Consultant_Num, Consultant_FName, Consultant_LName, Consultant_Phone,
Region_Num)
Consultant_Class (Consultant_Num, Class_Num)
Contract_Class (Contract_Num, Class_Num, Class_Time, Class_Date)
Contract (Contract_Num, Date_Signed, End_Date, Client_Num, Class_Num,
Contract_Amount)
Consultant_Contracts (Consultant_Num, Contract_Num, Consultant_Fee)
Client (Client_Num, Client_FName, Client_LName, Client_MInitial, Client_Address,
Client_Phone, Region_Num)

Page | 7

Region (Region_Num, Region_Name)

Assumptions

That all consultants make commission and get paid cash.


That we have a general understanding of our clientele.
That some data it is important to count consultants twice because they can be experts in

multiple classes.
That consultants can negotiate prices and that the prices listed are the finalized prices.
That Data that is 5 years or older is considered old and must be tossed.

Report Explanations
Report #1: This Report finds all of the clients who have not been under contract before. These
are people that could have possibly been inputted by accident or are in the system for other
things.
Report #2: This Report grabs all the clients that have signed into a contract this year. This is
important because there are contracts from the past that still happen to be in the system. It is
good to keep records but you want reports of the present as well.
Report #3: This Report tells the average amount a client paid for a contract throughout the year
2014 and 2015. This Report is important because it shows the average cost for a contract within
the most recent years. This allows you to focus on the present situation because cost raises and
lowers over time.
Report #4: This Report tells how many clients and consultants are within each region. This will
help the manager get a feel for where most of the clientele is coming from and if there is enough
consultants out there.
Report #5: This Report shows how many consultants are associated with a specific class. This is
helpful because it will solve if there are too many consultants for one class or if we need more.
So if needed they will be asked to just consult one class.
Report #6: This Report gives a count of how many classes we have that are for experts and
beginners. With this information knowing how many beginning classes or advanced classes we
have is important. This is because it will let the company know if they need subtract or add the
different level of classes.

Page | 8

Report #7: This Report shows the average consulting fee charged. This is important because
given the assumption that consultants make a commission and can negotiate. They are still part
of a firm that has restrictions and want to be loyal to the clients. So being able to get the average
consultant fee will allow us to tell if anyone is skewing the numbers.
Report #8: This Report shows all clients that have a contract that has ended five years from the
present year. This is because any contract that is 5 years old should be deleted from the database.
So by creating this collection you know exactly what needs to be deleted.
Report #9: This Report tells how many classes are running at a specific date and time. This
Report is important because like most Commercial areas, the place has only a certain amount of
rooms. So its good to know how many classes are going on at that specific time. This way its
easier to maintain how many rooms are filled up.
Report #10: This Report tells the sum of the contracts made in each region. This is important
because as a company you want to keep track of which region is making the most money and
which region is not doing as well.

REPORT SQL CODE


SELECT Client_Fname, Client_LName, Client_Minitial
FROM Client
WHERE NOT EXISTS (SELECT Client_Num FROM Contract
WHERE Client.Client_Num = Contract.Client_Num);
SELECT Client_Fname, Client_LName, Client_Minitial, Date_Signed
FROM Client, Contract
WHERE Contract.Client_num = Client.Client_num
and Contract.Date_Signed >= '2015-01-01'
SELECT AVG(Contract_Amount) AS Average_Contract_Price
FROM Contract
WHERE Contract.Date_Signed >= '2014-01-01'
SELECT Region_Name, COUNT(Client.Region_Num) AS CLIENT_AMOUNT
FROM Client, Regions
WHERE Client.Region_Num = Regions.Region_Num
GROUP BY Region_Name
SELECT Region_Name, COUNT(Consultant.Region_Num) AS Consultant_AMOUNT
FROM Consultant, Regions
WHERE Consultant.Region_Num = Regions.Region_Num
GROUP BY Region_Name;
SELECT Class_Name, COUNT(Consultant_Class.Class_Num) AS CONSULTANTS_ASC_CLS
FROM Class, Consultant_Class
WHERE Class.Class_Num = Consultant_Class.Class_Num
GROUP BY Class_Name
SELECT Class_Description, COUNT(Class_Description)AS AMOUNT_CLASS_LEVEL

Page | 9
FROM CLASS
GROUP BY Class_Description
SELECT AVG(Consultant_Fee)AS AVG_Consultant_Fee
FROM Consultant_Contracts
SELECT Client.Client_Num, Client_FName, Client_LName, End_Date
FROM Client, Contract
WHERE Client.Client_Num = Contract.Client_Num
AND Contract.End_Date <= '2010'
SELECT Class_Date, Class_Time, COUNT(Class_Time) AS CLASS_PER_TIME
FROM Contract_Class
GROUP BY Class_Time, Class_Date
SELECT Region_Name, SUM(Contract_Amount) AS REGION_INCOME
FROM Regions, Contract, Client
WHERE Regions.Region_Num = Client.Region_Num
AND Client.Client_Num = Contract.Client_Num
GROUP BY Region_Name

Relational Diagram

P a g e | 10

Vous aimerez peut-être aussi