select * from tab;
select * from employees;
select first_name,last_name from employees;
select first_name,salary,department_id,hire_date,job_id from employees where job_id='IT_PROG';
select first_name,job_id,salary,department_id from employees;
select first_name,job_id,salary,department_id from employees where department_id IN(20,50,70) and
salary>3000;
select first_name,job_id,salary,department_id from employees where department_id IN(20,50,70) and
salary BETWEEN 3000 and 5000;
select first_name,last_name,salary from employees where first_name LIKE 'K%';
select first_name,last_name,salary from employees where first_name LIKE '_elly';
select first_name,last_name,salary from employees where first_name LIKE '%a%';
select first_name,last_name,salary from employees where first_name LIKE 'E%';
select first_name,last_name,salary from employees where last_name LIKE '%a';
select first_name,last_name,salary from employees where first_name LIKE '%e%';
select first_name,last_name,salary from employees where first_name LIKE '_e%';
select first_name,last_name,salary from employees where first_name LIKE '_e%r';
select first_name,last_name,salary from employees where first_name LIKE '__e%';
select first_name,last_name,job_id from employees;
select first_name,last_name,job_id from employees where job_id='ST_CLERK';
select first_name,last_name,job_id from employees where job_id LIKE '%CLERK';
select first_name,last_name,salary,job_id from employees where job_id LIKE '%CLERK' and salary
BETWEEN 3000 and 5000;
select first_name,last_name,salary,department_id,job_id from employees where job_id LIKE '%CLERK'
and (salary BETWEEN 3000 and 5000 AND (department_id IN(80,50,40)));
desc employees;
select first_name,email from employees;
select first_name from employees;
select last_name,manager_id from employees where manager_id is null;
select first_name,salary,commission_pct from employees;
select first_name,salary,commission_pct from employees where commission_pct is null;
select first_name,salary,commission_pct from employees where commission_pct is not null;
select last_name,job_id from employees where job_id not IN('IT_PROG','ST_CLERK','SA_REP');
select last_name,department_id,salary from employees order by salary desc;
select last_name,department_id,salary from employees order by department_id ;
select last_name,department_id,salary from employees order by last_name ;
select last_name,department_id,salary from employees order by salary,last_name,department_id;
select last_name,department_id,salary*12 as annual from employees order by annual desc;
select last_name,department_id,salary from employees order by 3 ;
select last_name,department_id,salary from employees order by 1 ;
select last_name,department_id,salary from employees where department_id=&department_num;
select last_name,department_id,salary from employees where last_name=&name;
select last_name,salary from employees ;
select &col,salary from employees ;
select &col,salary from &table_name ;
select &col,salary,department_id from &table_name where department_id=&department ;
select &col1,&col2,department_id from &table_name where department_id=&department ;
select &col from &table_name where last_name=&name ;
select * from &table_name where last_name=&name ;
select salary from employees;
select avg(salary) from employees;
select max(salary) as max_salary,avg(salary) from employees;
select max(salary) as max_salary,avg(salary) from employees where department_id=30;
select max(hire_date) ,min(hire_date) from employees;
select count(first_name) from employees where department_id=80;
select max(salary) as max_salary,avg(salary),count(first_name) from employees where
department_id=80;
select count(department_id) from employees;
select count(distinct department_id) from employees;
select avg(commission_pct) from employees;
select avg(nvl(commission_pct,0)) from employees;
select avg(salary),department_id from employees group by department_id ;
select sum(salary) from employees;
select department_id,job_id,sum(salary)from employees where department_id=80 group by
job_id,department_id;
select department_id,avg(salary)from employees group by department_id;
select department_id,avg(salary)from employees group by department_id;
select first_name,last_name,job_id from employees;
select UPPER(first_name),LOWER(last_name),INITCAP(job_id) from employees;
select UPPER(first_name),(last_name),INITCAP(job_id) from employees where
LOWER(last_name)='higgins';
select CONCAT( CONCAT(first_name,' ' ),last_name),job_id from employees;
select SUBSTR(first_name,1,5),job_id from employees;
select SUBSTR(first_name,1,1),job_id from employees;
select SUBSTR(first_name,2,0),job_id from employees;
select first_name,last_name,job_id,salary from employees where job_id LIKE '%CLERK';
select first_name,last_name,job_id,salary from employees where SUBSTR(job_id,4,5)='CLERK' ;
select first_name,last_name,job_id,salary from employees where
SUBSTR(job_id,INSTR(job_id,'C'))='CLERK' ;
select first_name,last_name,job_id,salary from employees where
SUBSTR(job_id,INSTR(job_id,'C'),INSTR(job_id,'K')-INSTR(job_id,'C') )='CLERK' ;//
select LPAD(salary,10,0),job_id from employees;
select LPAD(first_name,10,'*'),job_id from employees;
select RPAD(first_name,10,'*'),job_id from employees;
select RPAD(salary,LENGTH(salary)+2,'RS'),job_id from employees;
select LENGTH(salary),salary from employees;
select first_name,last_name,INSTR(job_id,'C'),salary from employees ;
select job_id,INSTR(job_id,'K')-INSTR(job_id,'C') from employees;
select ROUND(2.378,2) from dual;
select TRUNC(2.378,2) from dual;
select MOD(27,4) from dual;
select TRUNC((salary*10/100),2) as salary from employees;
select TRUNC(2.378,0) from dual;
select TRUNC(avg(salary),2) from employees;
select SYSDATE from dual;
select last_name,(SYSDATE-hire_date)/7 as weeks from employees;
select last_name,(SYSDATE-hire_date)/12 as months from employees;//experience
select last_name,(SYSDATE-hire_date)/365 as year from employees;
select MONTHS_BETWEEN(SYSDATE,hire_date),department_id from employees;
select MONTHS_BETWEEN('01-JAN-2003','21-FEB-2001'),department_id from employees;//to calculate
months between 2 dates
select last_name,ADD_MONTHS(SYSDATE,3),department_id from employees;
select last_name,ADD_MONTHS('01-JAN-2002',3)from employees;
select last_name,NEXT_DAY('01-JAN-2002','SUNDAY')from employees;
select last_name,NEXT_DAY(hire_date,'FRIDAY')from employees;//
select last_name,hire_date from employees;
select last_name,LAST_DAY('20-MARCH-2002')from employees;//last day of month
select sysdate,ROUND(SYSDATE,'MONTH') from dual;
select sysdate,ROUND(SYSDATE,'YEAR') from dual;
select ROUND(TO_DATE('08-APR-2004'),'YEAR') from dual;
select ROUND(TO_DATE('08-DEC-2004'),'YEAR') from dual;
select sysdate,TRUNC(SYSDATE,'MONTH') from dual;
select sysdate,TRUNC(SYSDATE,'YEAR') from dual;
select TRUNC(TO_DATE('08-DEC-2004'),'YEAR') from dual;
select last_name, TO_CHAR(hire_date, 'fmDD Month YYYY') as HIREDATE from employees;
select salary, TO_CHAR(salary, '$99.9999.00') salary from employees;
select last_name,salary,commission_pct, salary*12 as annual, salary+commission_pct as total from
employees;
select last_name,salary,nvl(commission_pct,0), salary*12 as annual, salary+nvl(commission_pct,0) as
total from employees;