Uploaded by Pedro Panduko

TSA2

advertisement
Use the table above to answer the following by writing the SQL code. Do this code in sequential
order. Each number is related to the previous number.
1. Create the table above. Job_id is the primary key.
2. Add a new column on the table named job_category that accepts a string and it can be
null.
3. Using the new table, insert a new row on the Job_Temp table. Use the following data:
Job_id: ST_Assist, Job_title: Stock Aid, Min_Salary: 5000, Max_salary: 13000,
job_category: M_Operator.
4. Show the all the jobid, the sum of the salaries of the employees and the average of the
salaries of the employees that has an job id that ends with “ASST”. Group it by their
job_id. Show only the sum of the salary that are less than 5000. Then arrange it by
job_id. (Then show the table of the result when the SQL code is RUN)
CREATE TABLE JOB_TEMP (
JOB_ID VARCHAR2(10 BYTE) NOT NULL,
JOB_TITLE VARCHAR2(35 BYTE) NOT NULL,
MIN_SALARY NUMBER(6,0),
MAX_SALARY NUMBER(6,0),
PRIMARY KEY (JOB_ID)
);
ALTER TABLE JOB_TEMP
ADD JOB_CATEGORY VARCHAR2(255);
INSERT INTO JOB_TEMP(JOB_ID, JOB_TITLE, MIN_SALARY, MAX_SALARY, JOB_CATEGORY)
VALUES('ST_Assist', 'Stock Aid', 5000,13000, 'M_Operator');
Download