Recent Feedback
o Write a SQL query that joins two tables in the example database and uses BETWEEN to restrict record selection. Use salary to restrict data.Write a SQL query that joins two tables in the example database and uses BETWEEN to restrict record selection. Use hire dates to restrict data.Write a SQL query that joins two tables in the example database and uses LIKE to restrict record selection. Use telephone area codes to restrict data.Write a SQL query that joins two tables in the example database and uses LIKE to restrict record selection. Use age to restrict data.Write a SQL query that uses the UNION of the two tables to produce a third table.
Optional Information: Computer OS: Windows VistaBrowser: IE
Can i have a look at the database to be used??
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Employee]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Employee]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Job_title]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Job_title]
CREATE TABLE JOB_TITLE
(
eeo_1_class VARCHAR (20) NOT NULL,
job_title_id VARCHAR (5) PRIMARY KEY,
job_title VARCHAR (50) NOT NULL,
job_descrip VARCHAR (100) NOT NULL,
exempt VARCHAR (4) NOT NULL
)
CREATE TABLE EMPLOYEE
id_num INT IDENTITY (1, 1) PRIMARY KEY,
last_name VARCHAR (15) NOT NULL,
first_name VARCHAR(15) NOT NULL,
address VARCHAR (50) NOT NULL,
city VARCHAR (20) NOT NULL,
state VARCHAR (2) NOT NULL,
telephone_area_code VARCHAR (3) NOT NULL,
telephone_number VARCHAR (10) NOT NULL,
hire_date DATE NOT NULL,
salary DECIMAL (10,2),
gender CHAR(1) NOT NULL,
age INT NOT NULL,
job_title_id VARCHAR (5) CONSTRAINT FK_Employee_Job_title FOREIGN KEY REFERENCES Job_title (Job_title_id)
INSERT INTO JOB_TITLE VALUES
('Office Clerical','512','Accounting Clerk','Computes classifies records verifies numerical accounting data records','No');
('Officials Managers','043','Assistant Store Manager','supervises coordinate worker activities assists store manager','Yes');
('Sales Worker','496','Bagger','places customer orders in bags and cart carryout','No');
('Sales Workers', '472','Cashier','operates cash register to total customer purchases','No');
('Technician', '104','Computer Support Specialist','updates computers & provides training technical assistance','Yes');
('Officials Managers','082','Director of Finance & Accounting','plans directs finance and accounting activities','Yes');
('Craft Workers', '780','Retail Asst. Bakery & Pastry','obtains prepares baked goods','No');
('Operatives', '781','Retail Asst. Butchers & Seafood Specialist','obtains prepares meat items','No');
('Office Clerical','562','Stocker','restocks merchandise displays','No');
INSERT INTO EMPLOYEE VALUES
('Edelman', 'Glenn', '175 Bishops Lane', 'La Jolla', 'CA','619', '555-0199', 'Sales Workers', '07-OCT-2003',21500.75, 'M', 64, '472');
('McMullen', 'Eric', '763 Church St', 'Lemon Grove', 'CA', '619', '555-0135', 'Sales Workers',' 1-NOV-2002', 13500.00, 'M', 20, '496');
('Slentz', 'Raj', '123 Torrey Dr', 'North Clairmont', 'CA', '619', '555-0123', 'Officials Managers', '1-JUN-2000', 48000.00, 'M', 34, '043');
('Broun', 'Erin', '2045 Parkway Apt 2B', 'Encinitas', 'CA', '760', '555-0100', 'Sales Workers', '12-MAR-2003', 10530.00, 'F', 24,'496');
('Carpenter', 'Donald','927 Second St', 'Encinitas', 'CA', '619', '555-0154', 'Office Clerical', '1-NOV-2003', 15000.00, 'M', 18, '562');
('Esquivez', 'David', '10983 N. Coast Hwy Apt 902', 'Encinitas', 'CA', '760', '555-0108', 'Operatives', '25-JUL-2003', 18500.00, 'M',25, '781');
('Sharp', 'Nancy', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '12-JUL-2003', 21000.00, 'F', 24, '472');
('Chavez', 'Jose', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '19-NOV-2003', 16500.00, 'M', 19, '472');
('Chapman', 'Eden', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '13-SEP-2001', 17500.00, 'F', 32, '472');
('Munoz', 'Luis', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '31-MAR-2001', 14500.00, 'M', 22, '512');
('Miller', 'Art', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '29-SEP-2003', 15000.00, 'M', 19, '512');
('Vance', 'Brent', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '29-MAR-2001', 10530.00, 'M', 22, '472');
('Sobkowiak', 'Gregg', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '17-DEC-2001', 10920.00, 'M', 21, '472');
('Soper', 'Ken', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '16-APR-2003', 14500.00, 'M', 32, '472');
('Sobota', 'Linzee', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '09-JUN-2002', 14000.00, 'F', 21, '472');
('Spencer', 'Derea', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '11-APR-2003', 19500.00, 'M', 44, '472');
('Meier', 'Elaine', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '10-SEP-2000', 20500.00, 'F', 51, '472');
('Lopez', 'Margarita', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '27-DEC-2001', 20000.00, 'F', 52, '472');
('Merz', 'Angie', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '26-AUG-2000', 18000.00, 'F', 38, '472');
('Soukhone', 'Phanthousit', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '29-NOV-2002', 20500.00, 'M', 42, '472');
('Grayson', 'Mark', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '16-APR-2003', 18000.00, 'M', 21, '472');
('Bruss', 'Isarel', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '08-MAY-2001', 19000.00, 'M', 22, '472');
('Bakker', 'George', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '10-FEB-2003', 18500.00, 'M', 19, '472');
('Bareman', 'Chris', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '06-FEB-2002', 19000.00, 'M', 24, '472');
('Ball', 'David', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Craft Workers', '22-AUG-2000', 20500.00, 'M', 26, '472');
('Avery', 'Ledonna', '198 Governor Dr', 'Del Mar', 'CA', '619', '555-0135', 'Sales Workers', '28-MAR-2003', 21000.00, 'F', 23, '780');
('Tyink', 'Thomas', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Craft Workers', '01-MAY-2001', 19000.00, 'M', 32, '472');
('Urtado', 'Larissa', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Craft Workers', '05-FEB-2003', 19000.00, 'F', 35, '472');
('VanSlooten', 'Perry', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Crafts Workers', '12-DEC-2002', 19500.00, 'M', 24, '472');
('Quintero', 'Martha', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Crafts Workers', '16-JUN-2003', 19500.00, 'F', 26, '472');
('Quillian', 'Stan', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Operatives', '16-DEC-1999', 23000.00, 'M', 29, '781');
('Rayder', 'Patrick', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Operatives', '11-MAR-2002', 22500.00, 'M', 28, '781');
('Nitkowski', 'Aaron', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Operatives', '20-JAN-2002', 21500.00, 'M', 32, '781');
('Lopez-Palma', 'Fran', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Operatives', '28-MAR-2002', 20500.00, 'F', 27, '781');
('Lomax', 'Clay', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Operatives', '27-NOV-2001', 20600.00, 'M', 28, '781');
('Grewell', 'Cyndi', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '14-MAY-2003', 21000.00, 'F', 32, '472');
('Freeman', 'Gregory', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '14-MAY-2003', 19500.00, 'M', 31, '472');
('Garcia', 'Connie', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Sales Workers', '07-OCT-2001', 19500.00, 'F', 36, '472');
('Depree', 'Randy', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '07-DEC-1999', 34000.00, 'M', 40, '043');
('Cantu', 'Maria', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '03-MAR-2002', 37000.00, 'F', 45, '042');
('Chumakov', 'Fouay', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '01-AUG-2002', 40000.00, 'M', 26, '472');
('Vasquez', 'Emestina', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '22-JUL-2000', 38000.00, 'F', 27, '472');
('Thompson', 'Erin', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '01-MAY-1999', 47367.00, 'F', 28, '472');
('Drohos', 'Craig', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '15-JUN-2000', 51000.00, 'M', 32, '472');
('Priest', 'Laurie', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '01-JUN-1998', 67000.00, 'F', 34, '082');
('Stepka', 'Arthur', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '02-NOV-1999', 33000.00, 'M', 29, '472');
('Sams', 'Cecilia', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Professional', '25-SEP-2001', 35000.00, 'M', 31, '472');
('Wagner', 'Brenda', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '01-APR-1998', 60000.00, 'F', 44, '472');
('Santiago', 'Juanita', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '29-DEC-2001', 33000.00, 'F', 29, '472');
('Rilley', 'Arlyn', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '24-OCT-2001', 33000.00, 'M', 32, '472');
('Pitcher', 'Daniel', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '25-JUN-1999', 50000.00, 'M', 35, '472');
('Reynolds', 'Yvonne', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '10-APR-1998', 70000.00, 'F', 42, '472');
('Vu', 'Matthew', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Technician', '16-AUG-2000', 37000.00, 'M', 26, '472');
('Nguyen', 'Meredity', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Technician', '29-SEP-1998', 43000.00, 'F', 25, '472');
('Pighetti', 'Phillip', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '27-APR-2001', 24500.00, 'F', 27, '472');
('McNamara', 'Juanita', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Office Clerical', '29-OCT-1999', 25500.00, 'F', 32, '472');
('Stephens', 'Harvey', '10793 Montecino Rd', 'Ramona', 'CA', '858', '555-0135', 'Officials Managers', '01-MAR-1998', 75000.00, 'M', 51, '472');
Select * from employee
Select * from job_title
select * from employee join job_title on employee.job_title_id = job_title.job_title_id where salary between 13000 and 45000
select * from employee join job_title on employee.job_title_id = job_title.job_title_id where hire_date between '2000/01/01' and '2003/12/31'
select * from employee join job_title on employee.job_title_id = job_title.job_title_id where telephone_area_code like '6%'
select * from employee join job_title on employee.job_title_id = job_title.job_title_id where age like '2%'
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[New_table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[New_table]
select * into New_table from
(select eeo_1_class,job_title_id from employee
union
select eeo_1_class,job_title_id from job_title) A
select last_name from employee where eeo_1_class = 'sales workers'
select last_name from employee where salary > 30000
select last_name from employee where salary > 14000 and eeo_1_class = 'sales workers'
select last_name from employee join job_title on employee.job_title_id = job_title.job_title_id where salary > 20000 and exempt='yes'
OkI have got the databaseNow can you please specify what all optrations are to be performed on what tables??
Select employees' last names and group them by EEO-1 classification.
Select employees' last names and group them by salary.
Select employees' last names and group them by salary in their EEO-1 classification.
Select employees' last names and group them by salary in job titles, grouped into exempt and non-exempt.
You just need 4 Queries??
I need those four queries, but I need to do the join table also
Use the database and tables to write SQL queries using Between, Like, and Union:
Or to verify what I have done is correct
First two Query are as follows:select last_name,eeo_1_class from employee order by eeo_1_classselect last_name,salary from employee order by salaryOther two are confusing can you specify it in details
I need to separate employees based on area codes
The other one I need to join the two tables and be able to restrict employees by age ranges
No i am talking about these:
I see, I have 54 records and I need to list them all in the eeo class by salary
then all 54 records group by salary in their job title which should sort them by exempt or not.
did that help?
Just a second i am working on your JOIN Questions
ok
Ok i am done with all codes for Joinhere they are:SELECT e.first_name,e.last_name,e.address,jt.job_titleFROM employee e JOIN job_title jtON e.job_title_id = jt.job_title_idWHERE salary between 10000.00 AND 50000.00SELECT e.first_name,e.last_name,e.address,jt.job_titleFROM employee e JOIN job_title jtON e.job_title_id = jt.job_title_idWHERE hire_date between '01-JAN-2003' AND '31-DEC-2003'Select * from employeeSELECT e.first_name,e.last_name,e.address,jt.job_titleFROM employee e JOIN job_title jtON e.job_title_id = jt.job_title_idWHERE telephone_number LIKE '555-010_'SELECT e.first_name,e.last_name,e.address,jt.job_titleFROM employee e JOIN job_title jtON e.job_title_id = jt.job_title_idWHERE age LIKE '3_'AND this last one was already done by you:SELECT * INTO New_table FROM(SELECT eeo_1_class,job_title_id FROM employeeUNIONSELECT eeo_1_class,job_title_id FROM job_title) A
Experience: BE CS, 4+ Experience in Programming and Database (ERP)