Question: Please i need a SQL query if possible 1) Display all employee names (last name and first name separated by a comma and a space)

Please i need a SQL query if possible

1) Display all employee names (last name and first name separated by a comma and a space) and salary with appropriate column aliases. Also, for yearly salary display the local currency $ as its prefix. 2) Display all employees id and their position description who if commission is null, return only salary, otherwise return the sum of commission + salary. 3) Find all employees full names (lastname, firstname format) with salary, and their supervisors name with salary. 4) Find each employees salary information and level based on the salary. 5) Display employee names and dependent information. Also include those employees that dont have any dependent. 6) Find out the employee names and number of years worked along with their department names in descending order by number of years (up to two decimal points) worked. 7) Who works in the same department in which Heng Lee works? Display first name, last name and positon. Excluce Heng Lee as part of the output. 8) Which department has more employees than department 20? Display the department id and number of employee in the department. 9) Which employees are working in the company shorter than amin Muhammad? Display names and hire dates. 10) Find employees with maximum salary in their own department with the use of correlated subquery. 11) Find employee names whose last name start either with a D or C and second last character of first name is either an e or a n. 12) List the department name with the least number of employees. 13) List pair of employee names who are having the same qualification order by qualification id. 14) Display each employees name, department name, position description, and qualification description. Which employee is missing? Why? 15) Find the average (two decimal point), highest, lowest and total salary for each department. Name the colomn Average Salary, Maximum Salary and Minimum Salary and Total Salary. Also display the department id 16) Display all emloyee names and hire dates. Display hire dates with this format Thursday , 28 NOVEMBER 1996. 17) Find employee who were hired after year specified by the user (use subtititution variable) and use 1997 as your input. Display names and hire dates. 18) Display all employee names, department names, qalification descriptions, position descritions order by department name. 19) Display information for employee 128. Give a 10% raise to employee number 128. Again, display the updated information for emploee 128. 20) Delete department number 30 from the department table. If it is not successful, write down your suggestion to make it work.

_______________________________________________________________________________________________________

(The SQL table structure)

drop table emplevel cascade constraints;

drop table position cascade constraints;

drop table dept cascade constraints;

drop table employee cascade constraints;

drop table qualification cascade constraints;

drop table dependent cascade constraints;

CREATE TABLE emplevel

(SalaryLevel CHAR(1),

LowSalary NUMBER (6),

HighSalary NUMBER (6),

CONSTRAINT emplevel_levelno_pk PRIMARY KEY (SalaryLevel));

CREATE TABLE position

(PositionId CHAR (1),

PosDesc VARCHAR2 (10),

CONSTRAINT position_positionid_pk PRIMARY KEY (PositionId));

CREATE TABLE qualification

(QualId CHAR (1),

QualDesc VARCHAR2 (20),

CONSTRAINT qualification_qualid_pk PRIMARY KEY (QualId));

CREATE TABLE dept

(DeptId NUMBER (2),

DeptName VARCHAR2 (12) NOT NULL,

Location VARCHAR2 (20),

EmployeeId NUMBER (3),

CONSTRAINT dept_deptid_pk PRIMARY KEY (DeptId));

CREATE TABLE employee

(EmployeeId NUMBER (3),

Lname VARCHAR2 (15) CONSTRAINT employee_lname_nn NOT NULL,

Fname VARCHAR2 (15) CONSTRAINT employee_fname_nn NOT NULL,

PositionId CHAR (1),

Supervisor NUMBER (3),

HireDate DATE,

Salary NUMBER (6),

Commission NUMBER (5),

DeptId NUMBER (2) NOT NULL,

QualId CHAR (1),

CONSTRAINT employee_employeeid_pk

PRIMARY KEY (EmployeeId),

CONSTRAINT employee_positionid_fk FOREIGN KEY (PositionId)

REFERENCES position (PositionId),

CONSTRAINT employee_deptid_fk FOREIGN KEY (DeptId)

REFERENCES dept (DeptId),

CONSTRAINT employee_qualid_fk FOREIGN KEY (QualId)

REFERENCES qualification (QualId));

CREATE TABLE dependent

(EmployeeId NUMBER (3),

DependentId NUMBER (1),

DepDOB DATE,

Relation VARCHAR2 (8),

CONSTRAINT dependent_empiddepid_pk PRIMARY KEY (EmployeeId, DependentId),

CONSTRAINT dependent_employeeid_fk FOREIGN KEY (EmployeeId)

REFERENCES employee (EmployeeId));

INSERT INTO emplevel VALUES ('A', 1, 25000);

INSERT INTO emplevel VALUES ('B', 25001, 50000);

INSERT INTO emplevel VALUES ('C', 50001, 100000);

INSERT INTO emplevel VALUES ('D', 100001, 500000);

INSERT INTO position VALUES ('P', 'President');

INSERT INTO position VALUES ('M', 'Manager');

INSERT INTO position VALUES ('R', 'Programmer');

INSERT INTO position VALUES ('A', 'Accountant');

INSERT INTO position VALUES ('S', 'Salesman');

INSERT INTO qualification VALUES ('D', 'Doctorate');

INSERT INTO qualification VALUES ('M', 'Masters');

INSERT INTO qualification VALUES ('B', 'Bachelors');

INSERT INTO qualification VALUES ('H', 'Higher Diploma');

INSERT INTO qualification VALUES ('C', 'Certificate');

INSERT INTO dept VALUES (10, 'Finance', 'Kuala Lumpur', 123);

INSERT INTO dept VALUES (20, 'InfoSys', 'Cyberjaya', 443);

INSERT INTO dept VALUES (30, 'Sales', 'Subang Jaya', 135);

INSERT INTO dept VALUES (40, 'Marketing', 'Petaling Jaya', 246);

INSERT INTO employee VALUES (111, 'Lee', 'Heng', 'P', NULL,

TO_DATE ('04/15/1966', 'mm/dd/yyyy'), 265000, 35000, 10, 'D');

INSERT INTO employee VALUES (246, 'Krisna', 'Ananda', 'M', 111,

TO_DATE ('05/19/1967', 'mm/dd/yyyy'), 150000, 10000, 40, 'M');

INSERT INTO employee VALUES (231, 'Andiapan', 'Nagapan', 'A', 246,

TO_DATE ('06/13/1980', 'mm/dd/yyyy'), 85000, 8500, 40, 'B');

INSERT INTO employee VALUES (123, 'Raja', 'Vellu', 'M', 111,

TO_DATE ('12/02/1991', 'mm/dd/yyyy'), 105000, NULL, 10, 'M');

INSERT INTO employee VALUES (443, 'Ali', 'Fatimah', 'M', 111,

TO_DATE ('03/15/1995', 'mm/dd/yyyy'), 80000, 20000, 20, 'B');

INSERT INTO employee VALUES (433, 'Muhammad', 'Amin', 'R', 443,

TO_DATE ('05/10/1997', 'mm/dd/yyyy'), 66500, NULL, 20, 'H');

INSERT INTO employee VALUES (323, 'Salah', 'Kamuingat', 'R', 443,

TO_DATE ('01/01/1995', 'mm/dd/yyyy'), 76500, NULL, 20, 'B');

INSERT INTO employee VALUES (200, 'Seow', 'Jing', 'S', 135,

TO_DATE ('01/03/00', 'mm/dd/yy'), 24500, 3000, 30, NULL);

INSERT INTO employee VALUES (135, 'Chan', 'Hong', 'M', 111,

TO_DATE ('02/29/1996', 'mm/dd/yyyy'), 45000, 5000, 30, 'C');

INSERT INTO employee VALUES (322, 'Chen', 'Derek', 'A', 123,

TO_DATE ('08/15/1999', 'mm/dd/yyyy'), 75000, NULL, 10, 'B');

INSERT INTO employee VALUES (128, 'Din', 'Dong', 'R', 135,

TO_DATE ('02/29/1996', 'mm/dd/yyyy'), 38000, 8000, 30, 'C');

INSERT INTO employee VALUES (248, 'Chow', 'Fatt', 'A', 135,

TO_DATE ('08/15/1999', 'mm/dd/yyyy'), 30000, NULL, 10, 'B');

INSERT INTO dependent VALUES (443, 1, TO_DATE ('09/28/1968', 'mm/dd/yyyy'),

'Spouse');

INSERT INTO dependent VALUES (443, 2, TO_DATE ('10/14/1988', 'mm/dd/yyyy'),

'Son');

INSERT INTO dependent VALUES (200, 1, TO_DATE ('06/10/1976', 'mm/dd/yyyy'),

'Spouse');

INSERT INTO dependent VALUES (322, 1, TO_DATE ('02/04/1975', 'mm/dd/yyyy'),

'Spouse');

INSERT INTO dependent VALUES (322, 2, TO_DATE ('08/23/1997', 'mm/dd/yyyy'),

'Son');

INSERT INTO dependent VALUES (322, 3, TO_DATE ('07/10/1999', 'mm/dd/yyyy'),

'Daughter');

INSERT INTO dependent VALUES (111, 1, TO_DATE ('12/12/1965', 'mm/dd/yyyy'),

'Spouse');

ALTER TABLE dept

ADD CONSTRAINT dept_employeeid_fk FOREIGN KEY(EmployeeId)

REFERENCES employee(EmployeeId);

ALTER TABLE employee

ADD CONSTRAINT employee_supervisor_fk FOREIGN KEY(Supervisor)

REFERENCES employee(EmployeeId);

commit;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!