Site icon IT Tutorial

Oracle SQL Tutorials – Chapter 2 (Part 3 of 3)

OPERATOR PRECEDENCE

 

SELECT first_name,last_name, job_id, salary 
FROM hr.employees 
WHERE job_id = 'SA_REP‘ OR job_id = 'AD_PRES‘ AND salary > 15000;

 

This way, all employess which JOB_ID is SA_REP listed as result. We need to add parenthesis to correct this querry ;

SELECT first_name,last_name, job_id, salary 
FROM hr.employees 
WHERE (job_id = 'SA_REP‘ OR job_id = 'AD_PRES‘) AND salary > 15000;

 

ORDER BY OPERATOR

SELECT first_name,last_name, job_id, department_id, hire_date "Hire Date“ 
FROM hr.employees 
ORDER BY hire_date ASC ;

 

SELECT employee_id, first_name,last_name, salary*12 "Yearly Salary“
FROM hr.employees
ORDER BY 4 desc ;

 

ASSIGNING VARIABLE

SELECT employee_id, last_name, salary, department_id
FROM hr.employees
WHERE department_id = &department_num ;

Exit mobile version