•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 370,613 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,101 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser:
Views: 1251 | Replies: 3
![]() |
hello, ive been busy trying over and over and over again to write a block of SQL that will perform this task for me but have failed ever time. hopefully someone can point me in the right direction or at least gime a hand cheers.
task : to work out what is the average cost of hire contracts for each of the five branches?
i have 5 tables set up
which are as follows
and as the question states i need to work out the average cost of hire contracts for each branch. The tables have been set up this way on purpose but i just cannot seem to find a way to achieve this goal ? any ideas.
task : to work out what is the average cost of hire contracts for each of the five branches?
i have 5 tables set up
which are as follows
/* creates the Branch table
primary key 'BranchNo' */
CREATE TABLE Branch (
BranchNo NUMBER(3) CONSTRAINT pk_branch PRIMARY KEY ,
BranchName VARCHAR2(28) ,
BranchAddress VARCHAR2(40) ,
City VARCHAR2(18) ,
B_tel_no VARCHAR2(12) );
/* creates the staff table
primary key 'StaffID'
foreign key 'BranchNo' */
CREATE TABLE Staff (
StaffID NUMBER(3) CONSTRAINT pk_staff PRIMARY KEY ,
StaffName VARCHAR2(20) ,
BranchNo NUMBER(3) CONSTRAINT fk_BranchNo references Branch(BranchNo) ,
JobTitle VARCHAR2(20) );
/* creates the Customer table
primary key 'CustomerNo' */
CREATE TABLE Customer (
CustomerNo NUMBER(3) CONSTRAINT pk_customer PRIMARY KEY ,
CustomerName VARCHAR2(20) ,
CustomerAddress VARCHAR2(48) ,
CustomerTelNo VARCHAR2(12) );
/* creates the Car table
primary key 'CarRegNo' */
CREATE TABLE Car (
CarRegNo NUMBER(3) CONSTRAINT pk_car PRIMARY KEY ,
CarTypeNo VARCHAR2(28) ,
CarModel VARCHAR2(48) ,
Colour VARCHAR2(18) ,
Mileage NUMBER(7) );
/* creates the Type table
primary key 'CarTypeNo' */
CREATE TABLE Type (
CarTypeNo NUMBER(3) CONSTRAINT pk_type PRIMARY KEY ,
TypeDescription VARCHAR2(48) ,
DailyCharge NUMBER(5,2) );
/* creates the HireContract table
primary key 'Hire_Contract_No' & 'CarRegNo'
foreign key 'CarRegNo' & 'CustomerNo' */
CREATE TABLE HireContract (
Hire_Contract_No NUMBER(3) ,
CarRegNo NUMBER(3) CONSTRAINT fk_CarRegNo references Car(CarRegNo),
CustomerNo NUMBER(3) CONSTRAINT fk_CustomerNo references Customer(CustomerNo),
StaffID NUMBER(3) ,
CarTypeNo VARCHAR2(3) ,
IssueDate DATE ,
DueReturnDate DATE ,
ActualReturnDate DATE ,
CarCost NUMBER(6,2) ,
CONSTRAINT pk_Hire PRIMARY KEY(Hire_Contract_No, CarRegNo) ,
CONSTRAINT ch_ActualReturnDate CHECK (ActualReturnDate > IssueDate) ,
CONSTRAINT ch_DueReturnDate CHECK (DueReturnDate > IssueDate) );and as the question states i need to work out the average cost of hire contracts for each branch. The tables have been set up this way on purpose but i just cannot seem to find a way to achieve this goal ? any ideas.
•
•
Join Date: Feb 2007
Location: London
Posts: 114
Reputation:
Rep Power: 2
Solved Threads: 8
Without answering your whole question I'll give you a start
You need 3 of the tables to find cost per hire -
HireContract
Staff
Branch
Join them to each other and you should then be able to find the contracts for each branch (join fields are StaffID and BranchNo)
Give it a go and post here when your done
Cheers
D
You need 3 of the tables to find cost per hire -
HireContract
Staff
Branch
Join them to each other and you should then be able to find the contracts for each branch (join fields are StaffID and BranchNo)
Give it a go and post here when your done
Cheers
D
•
•
•
•
Without answering your whole question I'll give you a start
You need 3 of the tables to find cost per hire -
HireContract
Staff
Branch
Join them to each other and you should then be able to find the contracts for each branch (join fields are StaffID and BranchNo)
Give it a go and post here when your done
Cheers
D
hello, cheers for the reply i actually managed to figure it out myself
after a long and painful process. Really am greatful for the help though. Thanks .. ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
Similar Threads
- Programming (C++)
- How come Windows are much more complicated now (Windows NT / 2000 / XP / 2003)
- Java seems complicated... (Java)
- WMP Internal Application Error- very complicated! (Viruses, Spyware and other Nasties)
- Duplication (C++)
- MySQL vs. PostgreSQL (MySQL)
- Java vs Java3D (Java)
- iis 5 through linksys wireless 4prt switch firewal (Windows NT / 2000 / XP / 2003)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the Oracle Forum
- Previous Thread: SQLCA Error
- Next Thread: Sometimes an error come out "Could not connect to database".Why??


Linear Mode