You are on page 1of 18

LAB TASK # 02

NAME: ZAIN UL ABIDEEN


SAP: 35515.
SECTION: CS4-1.
INSTRUSTOR: QAZI SHUJA UDDIN.
DATED: 17-MARCH-2023
QUESTION # 01
(AND – OR – NOT IN)
AND:
Example#01:
SELECT job_id,min_salary
from jobs
where max_salary = 40000
AND job_title = 'President';
Example#02:
SELECT start_date,end_date
from job_history
where department_id = 110
AND job_id = 'AC_ACCOUNT';
Example#03:
SELECT employee_id, job_id
from employees
where employee_id = 131
AND job_id ='ST_CLERK';

OR:
Example#01:
SELECT employee_id,first_name, job_id ,salary
from employees
where salary>=1100
or job_id ='IT_PROG';
TASK#01:
SELECT salary,job_id
from employees
where salary>4000
or job_id ='IT_PROG';
TASK#02:
SELECT country_id,country_name
from countries
where region_id=4
or country_name ='argentina';

NOT-IN:
Example#01:
Example 01
Select first_name,job_id
From employees
Where job_id not in ('ST_CLERK', 'PROGRAMMER')
TASK#01:
Select employee_id,salary
From employees
Where department_id not in (50, 80)
TASK#02:
Select *
From job_history
Where job_id not in ('IT_PROG', 'AC_ACCOUNT')

AND-OR:
Example#01:

SELECT first_name, job_id ,salary


from employees
where job_id='ST_CLERK'
or job_id ='IT_PROG'
and salary >6000;
Example#02:
SELECT first_name, job_id ,salary
from employees
where ( job_id='ST_CLERK' or job_id ='IT_PROG')
and salary >6000;
QUESTION # 02
(ORDER BY)

ORDER BY:
Example#01:
SELECT first_name, job_id ,department_id,hire_date
from employees
order by hire_date asc ,first_name asc;

Example#02:
SELECT first_name, job_id ,department_id,hire_date
from employees
order by hire_date desc;
Example#03:
SELECT employee_id,first_name,salary *12 as annualsalary
from employees
order by annualsalary ;
Example#04:
SELECT first_name,department_id,salary
from employees
order by department_id , salary desc;

TASK#01:
SELECT *
from countries
order by country_name desc;
QUESTION # 03
(FUNCTIONS)
CHARACTER MANIULATION FUNCTION:

Example#01:
SELECT first_name, CONCAT (first_name, job_id ),
LENGTH (first_name), INSTR (first_name,'A')
FROM employees
WHERE department_id=110;

TASK#01:
SELECT CONCAT (first_name, last_name )
FROM employees
WHERE first_name like '%a'
AND salary in ( 6000, 8400, 8600, 6100)
TASK#02:
SELECT CONCAT (first_name, last_name ),
RPAD(first_name, 10, ' ')
FROM employees;
CASE CONVERTION FUNCTIONS:

Example#01:
SELECT employee_id, last_name,department_id
FROM employees
WHERE LOWER (last_name)=’higgins’;

TASK#01:
SELECT LOWER(country_name)
FROM countries
TASK#02:
SELECT upper(concat(first_name, last_name))
as "Full_Name"
FROM employees
where salary between 6000 and 12000;
QUESTION # 04
(DUAL FUNCTION)

DUAL:
Example#01:
SELECT first_name, salary, MOD (salary ,5000)
FROM employees
WHERE job_id =’SA_REP’;

You might also like