Creating a view between two tables in SQL -


i'm having trouble creating view between 2 tables, i'm quite new sql. need create view show employees have carried out work consultants within past 14 days. result of view should display kind of layout:

14 day consultancy report  ----------------------------------------------- employee helvin paul worked 6 hours factory ltd chargeable £351 

the 2 tables assume need join employee table , consultancy table. show both below have them in text file when creating these tables:

create table funtom_employee  (     emp_id      number(3)  primary key,         emp_firstname   varchar2(50) not null,     emp_surname varchar2(50),     emp_department  number(2) constraint fk_funtom_dept references      funtom_department,     emp_street  varchar2(50),     emp_town    varchar2(50),     emp_district    varchar2(50),     emp_grade   number(3) default 4 constraint chk_emp_grd check (emp_grade between 1 , 9),     emp_site    varchar2(30) default 'london',      constraint  fk_funtom_grade funtom_grade references funtom_department );  create table funtom_consultancy (     consultancy_id  number(3) primary key,     consultancy_emp number(3) constraint cns_emp references funtom_employee,     consultancy_hours   number(4,2) constraint consultancy_check check (consultancy_hours > 1),     consultancy_client  number(3) references funtom_customer,     consultancy_date    date,     consultancy_activity    number(3) references funtom_activity ); 

thanks can create view , time

a view can created using create view statement. example based on data listed below.

create view consultancy_report  select     funtom_employee.emp_firstname,     funtom_consultancy.consultancy_date,     funtom_employee     join funtom_consultancy         on funtom_employee.emp_id = funtom_consultancy.consultancy_emp 

you can add whatever other fields need either table in select clause of query. i've demonstrated 1 field both tables.

if want output explicitly listed in sample, need concatenate several fields 1 string. since feels homework question, leave exercise you.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -