Practical 4 21ss02it056

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

JASH SABHAYA 21ss02it056 c7

Practical – 4

Aim: Answer the Following Queries


Reference Table Country Master

1) Count all the employees who live in the REGION_ID 2.


Query: select count(REGION_ID) from countrymaster3 WHERE
REGION_ID='2';
Output

2) Count the total number of employees who live in the ‘United States of America’ and
‘Germany’.
Query: select count(*) from countrymaster3 WHERE COUNTRY_NAME ='united states of
america' OR COUNTRY_NAME='germany';

Output:

1|Page
JASH SABHAYA 21ss02it056 c7

3) Count all the employees who live in the Country_Name


starting with ‘Un’.
Query: select count(*) from countrymaster3 WHERE
COUNTRY_NAME like 'un%';
Output

4) Find the substring America from the keyword ‘United States of


America’.
Query: select substr('united states of america',-7,7) "substring" from
CountryMaster3;
Output

2|Page
JASH SABHAYA 21ss02it056 c7

B) Reference Table Department Master

5) Find all the departments which contain Location_id starting with


17.
Query: select DEPARTMENT_NAME from DepartmentMaster1 where
LOCATION_ID like '17%';
Output

6) Find the department name which contains the highest


manager_id number.
Query: select Department_Name from DepartmentMaster1 where
Manager_ID = (select Max(Manager_ID) from Departmentmaster1);
OUTPUT

3|Page
JASH SABHAYA 21ss02it056 c7

7) Find the substring ‘ppi’ from the Department_Name field.


Query:
Output

8) Find the total length of the string ‘P P Savani University’ using


String SQL functions.
Query: SELECT LENGTH('P P SAVANI UNIVERSITY') FROM DUAL;
Output

C) Reference Table Employee Master

4|Page
JASH SABHAYA 21ss02it056 c7

9) Find all the employees who are earning salary greater than
5000 rupees and sort themas per their hiring date.
Query: select * from EmployeeMaster1 where SALARY>5000 order by
HIRE_DATE ASC;
Output

5|Page
JASH SABHAYA 21ss02it056 c7

10) Give promotion of 10% to salary and display it as New Salary


for all the employees who are working as IT programmers in a
company.
Query: select salary+salary*.1 from EmployeeMaster1 where JOB_ID in
'IT_PROG';
Output

11) Double the salary of all the employees who are working as
‘Senior Clerk’ in the company.
Query: select salary*2, job_id from EmployeeMaster1 where job_id in
'ST_CLERK';
Output

12) Find employees with the department id is 10, 20, or 60.

6|Page
JASH SABHAYA 21ss02it056 c7

a) Query: select * from EmployeeMaster1 where


DEPARTMENT_ID=10 OR DEPARTMENT_ID=20 OR
DEPARTMENT_ID=60;
Output

7|Page
JASH SABHAYA 21ss02it056 c7

b) Query: select * from EmployeeMaster1 where DEPARTMENT_ID


in (10,20,60);
Output

D) Reference Table Job Master

8|Page
JASH SABHAYA 21ss02it056 c7

13) Find all the job titles whose minimum earning between 6000
to 10000 rupees and arrange them in descending order as per
their maximum salary.
Query: select JOB_TITLE from JobMaster where MIN_SALARY between
'6000' and '10000' order by MAX_SALARY DESC;
Output

14) select JOB_TITLE from JobMaster where MIN_SALARY


between '6000' and '10000' order by MAX_SALARY DESC;
Query: select * from JobMaster where JOB_TITLE like 'admin%' or
JOB_TITLE
Output

15) List out all the rows where job_id starts from ‘AD_’ to ‘ST_’.

9|Page
JASH SABHAYA 21ss02it056 c7

Query: select * from JobMaster where JOB_ID like 'AD_%' or JOB_ID


like 'ST_%';
Output

E) Reference Table Location Master

16) Count the all employees who live in the postal_code starting
with ‘9’ and ‘O’.
Query: select COUNT(*) from locationmaster where POSTAL_CODE like
'9%' or POSTAL_CODE like'0%';
Output

10 | P a g e

You might also like