See current output starting at page
DROP TABLE EMPLOYEE;
DROP TABLE JOB_TITLE;
Create Table EMPLOYEE
(
EMP_ID int NOT NULL,
LAST_NAME varchar(20) NOT NULL,
FIRST_NAME varchar(20) NOT NULL,
EMP_ADDRESS varchar(25) NOT NULL,
EMP_CITY varchar(25) NOT NULL,
EMP_STATE char(2) NOT NULL,
AREA_CODE int NOT NULL,
PHONE_NUM int NOT NULL,
HIRE_DATE datetime NOT NULL,
SALARY money NOT NULL,
GENDER char(5) NOT NULL,
AGE int NOT NULL
JOB TITLE varchar(50) NOT NULL
CONSTRAINT EMP_ID_PK PRIMARY KEY (EMP_ID)
);
Insert into Employee values(1,'Edelman' ,'Glenn' ,'175 N.Bishops LN' ,'La Jolla' ,'CA','619','5550199','10/07/2003','21500','M','64','Cashier');
Insert into Employee values(2,'McMullen' ,'Eric' ,'763 Church ST' ,'Lemon Grove' ,'CA','619','5550133','11/01/2002','13500','M','20','Cashier');
Insert into Employee values(3,'Slentz' ,'Raj' ,'123 Torrey Dr' ,'North Clairmont','CA','619','5550123','06/01/2000','48000','M','34','Cashier');
Insert into Employee values(4,'Broun' ,'Eric' ,'2045 Park Way' ,'Encinatas' ,'CA','760','5550100','03/12/2003','10530','M','24','Cashier');
Insert into Employee values(5,'Carpenter','Donald','927 2ND ST' ,'Encinatas' ,'CA','619','5550154','11/01/2003','15000','M','18','Cashier');
Insert into Employee values(6,'Esquivez' ,'David' ,'10983 N. Coast Hwy.','Encinatas' ,'CA','619','5550158','07/25/2003','18500','M','25','Cashier');
Insert into Employee values(7,'Sharp' ,'Nancy' ,'10793 Montecito LN' ,'Ramona' ,'CA','858','5550135','07/12/2003','21000','F','24','Cashier');
Create Table JOB_TITLE
(
Job_title varchar(50) NOT NULL,
Job_description varchar(50) NOT NULL,
Emp_exempt_status char (2) NOT NULL,
EEO1_classification varchar(25) NOT NULL,
CONSTRAINT JOB_TITLE_PK PRIMARY KEY (JOB_TITLE)
);
Insert into JOB_TITLE values('Accounting Clerk' ,'maintain accounting records' ,'NE','Office Clerical');
Insert into JOB_TITLE values('Assistant Manager' ,'assist store managers' ,'E' ,'Officials and managers');
Insert into JOB_TITLE values('Bagger' ,'Bag Purchases-carryout when needed' ,'NE','Sales Worker');
Insert into JOB_TITLE values('Cashier' ,'Cash handling-itemize customer orders','NE','Sales Worker');
Insert into JOB_TITLE values('Computer Support Specialist' ,'maintain PC systems' ,'NE','Technician');
Insert into JOB_TITLE Values('Director of Finance and Accounting' ,'Directs financial activities' ,'E' ,'Officials & Managers');
Insert into JOB_TITLE values('Retail Assistant-bakery and Pastry' ,'Handle Customer Requests' ,'NE','Operatives(semi-skilled)');
Insert into JOB_TITLE Values('Retail Assistant-butcher and seafood','Handle Custoemr Requests' ,'NE','Operatives(semi-skilled)');
Insert into JOB_TITLE Values('Stocker' ,'Store, price, restock Inventory' ,'NE','Office-Clerical');
select * from EMPLOYEE;
select * from JOB_TITLE;
select *
from EMPLOYEE,JOB_TITLE
where EMPLOYEE.JOB_TITLE=JOB_TITLE.JOB_TITLE;
--DROP TABLE EMPTEST;
CREATE TABLE EMPTEST(EMP_ID INT IDENTITY(1,1),NAME VARCHAR(10));
INSERT INTO EMPTEST VALUES('FRED' );
INSERT INTO EMPTEST VALUES('WILMA' );
INSERT INTO EMPTEST VALUES('BARNEY');
INSERT INTO EMPTEST VALUES('BETTY' );
INSERT INTO EMPTEST VALUES('DINO' );
SELECT * FROM EMPTEST;
/* WEEK THREE ASSIGNMENT */
/* NUMBERS 1 - 4 */
/* SQL QUERIES */
SELECT LAST_NAME, FIRST_NAME,EMP_City,EMP_State,JOB_DESCRIPTION,
FROM EMPLOYEE,JOB_TITLE
WHERE Salary BETWEEN 10000 and 20000;
SELECT LAST_NAME, FIRST_NAME, Hire_Date, Age,
FROM EMPLOYEE,JOB_TITLE
WHERE Emp_exempt_status="E";
SELECT LAST_NAME, FIRST_NAME,EMP_CITY,
FROM EMPLOYEE,JOB_TITLE
WHERE AGE > 25, EMP_STATE=C;
SELECT LAST_NAME, FIRST_NAME,AGE, JOB_DESCRIPTION
from EMPLOYEE,JOB_TITLE,
WHERE EMP_CITY LIKE "E",GENDER;
/* WEEK THREE ASSIGNMENT */
/* NUMBERS 5-7 */
/*GROUP BY STATEMENTS */
/* JOB DESCRIPTION */
SELECT LAST_NAME, FIRST_NAME, COUNT (*)
FROM (EMPLOYEE,JOB_TITLE),
GROUP BY JOB_DESCRIPTION));
SELECT LAST_NAME, FIRST_NAME,
FROM (EMPLOYEE,JOB_TITLE)
GROUP BY STATE HAVING "C"));
SELECT LAST_NAME, FIRST_NAME,
FROM (EMPLOYEE,JOB_TITLE)
GROUP BY EMP_EXEMPT_STATUS));
OUTPUT
Msg 102, Level 15, State 1, Line 18
Incorrect syntax near 'JOB'.
Msg 156, Level 15, State 1, Line 75
Incorrect syntax near the keyword 'FROM'.
Msg 156, Level 15, State 1, Line 79
Incorrect syntax near the keyword 'FROM'.
Msg 156, Level 15, State 1, Line 83
Incorrect syntax near the keyword 'FROM'.
Msg 156, Level 15, State 1, Line 89
Incorrect syntax near the keyword 'WHERE'.
Msg 102, Level 15, State 1, Line 100
Incorrect syntax near ','.
Msg 156, Level 15, State 1, Line 105
Incorrect syntax near the keyword 'FROM'.
Msg 156, Level 15, State 1, Line 110
Incorrect syntax near the keyword 'FROM'.
Troy382438 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.