Professional Documents
Culture Documents
no rows selected
=======================================================================
=======================================================================
===================================================================================
===========================================================
Expression:-
By considering two or more operant and using some operation we can get some
output it is known as expression.
===================================================================================
===========================================================
Q. WAQTD ename, sal, monthly salary, mid term salary, quarter sal, 1000 rs bonus
for monthly salary.
SQL> select ename, sal, job, sal*12, sal*6, sal*3, 1000+sal from emp;
===================================================================================
================================================================
Q. WAQTD emp name, sal, job, annual sal, 1000 rs bonus for monthly for midterm sal,
1000 rs deduction for monthly salary.
SQL> select ename, sal, job, sal*12, 1000+(sal*6), 1000-sal from emp;
ENAME SAL JOB SAL*12 1000+(SAL*6) 1000-SAL
---------- ---------- --------- ---------- ------------ ----------
SMITH 800 CLERK 9600 5800 200
ALLEN 1600 SALESMAN 19200 10600 -600
WARD 1250 SALESMAN 15000 8500 -250
JONES 2975 MANAGER 35700 18850 -1975
MARTIN 1250 SALESMAN 15000 8500 -250
BLAKE 2850 MANAGER 34200 18100 -1850
CLARK 2450 MANAGER 29400 15700 -1450
SCOTT 3000 ANALYST 36000 19000 -2000
KING 5000 PRESIDENT 60000 31000 -4000
TURNER 1500 SALESMAN 18000 10000 -500
ADAMS 1100 CLERK 13200 7600 -100
JAMES 950 CLERK 11400 6700 50
FORD 3000 ANALYST 36000 19000 -2000
MILLER 1300 CLERK 15600 8800 -300
===================================================================================
====================================================================
Q. WAQTD salary, annual salary, midterm salary 10% increament for monthly salary.
===================================================================================
==========================================================
Q. WAQTD empname, sal, 20% increament for monthly salary, 10% decrement for monthly
commission.
===================================================================================
=============================================================
Q. WAQTD empname, sal, job, 30% increament for monthly salary, 35% decrement for
monthly commission.
===================================================================================
==================================================================
===================================================================================
=================================================================
Q. WAQTD empname, sal, midterm salary, 25% increament for quarter salary, 10%
decrement for quarter commission.
SQL> select ename, sal, sal*6, (sal*3)*1.25, (comm*3)*0.9 from emp;
===================================================================================
===================================================================
ENAME SAL
---------- ----------
SMITH 800
ALLEN 1600
WARD 1250
JONES 2975
MARTIN 1250
BLAKE 2850
CLARK 2450
SCOTT 3000
KING 5000
TURNER 1500
ADAMS 1100
JAMES 950
FORD 3000
MILLER 1300
===================================================================================
===============================================================
SAL
----------
2450
5000
1300
1250
2850
2975
1100
3000
800
1600
1500
950
===================================================================================
==============================================================
Distinct:-
It is a keyword used to display unique value at the time of execution.
===================================================================================
===============================================================
Q. WAQTD unique job for employee table.
JOB
---------
CLERK
SALESMAN
PRESIDENT
MANAGER
ANALYST
===================================================================================
=================================================================
DEPTNO
----------
30
20
10
===================================================================================
=================================================================
Q. WAQTD empname, sal, job, annualsalary, 10% increament for midterm salary.
4 rows selected.
Alias Name :
It is a alternate name given to the column or expression at the time of
execution.
===================================================================================
================================================================
Q. WAQTD ename, annual salary, midterm sal from emp table.
SQL> select ename empname, sal*12 "ANN SAL", sal*6 MID_Term_Sal from
emp;
===================================================================================
==================================================================
Q. WAQTD ename, sal, job if the ename is SMITH.
SQL> select ename, sal, job from emp where ename = 'SMITH';
===================================================================================
=================================================================
Q. WAQTD ename, sal, if they are getting sal more than 1000.
SQL> select ename, sal from emp where sal > 1000;
ENAME SAL
---------- ----------
ALLEN 1600
WARD 1250
JONES 2975
MARTIN 1250
BLAKE 2850
CLARK 2450
SCOTT 3000
KING 5000
TURNER 1500
ADAMS 1100
FORD 3000
MILLER 1300
===================================================================================
===================================================================
SQL> select ename, sal, job from emp where JOB = 'MANAGER';
===================================================================================
==================================================================
===================================================================================
===================================================================
Q. WAQTD ename, sal, hiredate if they are hired after 1981.
SQL> select ename, sal, hiredate from emp where hiredate > '31-DEC-1981';
===================================================================================
=====================================================================
Q. WAQTD ename, sal, empno from emp where empno=7839.
===================================================================================
================================================================
Q. WAQTD all the details from emp whos is working as a Manager in depno 10.
===================================================================================
================================================================
Q WAQTD ename, job, sal if they are working as salesman and getting sal more than
3000.
no rows selected
===================================================================================
================================================================
Q. WAQTD empname, job, deptno if they are working as analyst or if they are working
in deptno 10.
SQL> SELECT ENAME, JOB, DEPTNO
2 FROM EMP
3 WHERE JOB='ANALYST' OR DEPTNO='10';
Date:- 30-SEP-2022
Q. WAQTD employee name, sal, dept no, job if they are getting sal more than 2000 in
dept no 10 or working as manager.
===================================================================================
================================================================
Q. WAQTD all the details of employee if they are working in dept no 10, 20, 30.
SQL> SELECT *
2 FROM EMP
3 WHERE DEPTNO IN(10, 20, 30);
14 rows selected.
===================================================================================
================================================================
Q. WAQTD emp name, sal if the employee are getting sal of 950, 1250, 1500, 3000 and
5000 in dept no 10, 20, 30.
ENAME SAL
---------- ----------
WARD 1250
MARTIN 1250
SCOTT 3000
KING 5000
TURNER 1500
JAMES 950
FORD 3000
7 rows selected.
===================================================================================
================================================================
Q. WAQTD ename, job if they are working as manager, analyst, salesman.
ENAME JOB
---------- ---------
ALLEN SALESMAN
WARD SALESMAN
JONES MANAGER
MARTIN SALESMAN
BLAKE MANAGER
CLARK MANAGER
SCOTT ANALYST
TURNER SALESMAN
FORD ANALYST
9 rows selected.
===================================================================================
================================================================
Q. WAQTD ename, deptno if the employee is not working in dept no 10, 20.
SQL> SELECT ENAME, DEPTNO
2 FROM EMP
3 WHERE DEPTNO IN ('10', '20');
ENAME DEPTNO
---------- ----------
SMITH 20
JONES 20
CLARK 10
SCOTT 20
KING 10
ADAMS 20
FORD 20
MILLER 10
8 rows selected.
===================================================================================
================================================================
Q. WAQTD ename, sal, comm if the employee are getting sal more than 2000 and
getting some comm.
===================================================================================
================================================================
Q. WAQTD ename, job, comm if the employees are working in some job and not getting
any comm.
===================================================================================
================================================================
Q. WAQTD ename, job, comm, dept no if they are getting sal more than 2000 and
getting some comm and working in some dept and hired after 1980.
no rows selected
===================================================================================
================================================================
ENAME JOB
---------- ---------
ALLEN SALESMAN
ADAMS CLERK
===================================================================================
================================================================
Q. WAQTD all the details of employee if they working in deptno 10, 20, and getting
some sal between 2000 to 3000 and job ends with man.
Q. WAQTD employee name, sal if they are getting sal more than 2000 and less than or
equal to 5000.
Q. WAQTD employee name, sal, job if they are getting sal less than 300 and more
than 1000.
Q. WAQTD employee name, sal if they are getting sal less than or equal to 300 and
more than 1000.
Q. WAQTD ename, comm if they are getting comm less or equal to zero and greater
than or equal to 500.
Q. WAQTD max sal , min sal , ename if the ename starts with a.
===================================================================================
================================================================
12-10-2022
Q. WAQTD max sal, job which is from emp table.
Q. WAQTD max sal, min sal in each dept if they are getting sal more than 1000 and
max sal more than 2000.
Q. WAQTD max sal, min sal if max sal is more than 3000.
Q. WAQTD employee name , max sal if avg sal is less than 2000.
SAL
----------
2450
5000
1300
1250
2850
2975
1100
3000
800
1600
1500
950
12 rows selected.
COUNT(ENAME) DEPTNO
------------ ----------
6 30
5 20
3 10
COUNT(ENAME) DEPTNO
------------ ----------
6 30
5 20
HIREDATE
---------
03-DEC-81
no rows selected
Q. WAQTD sal if they are getting sal is more than 2000 and arrange the op in
descending order
1 SELECT SAL
2 FROM EMP
3 WHERE SAL > 2000
4* ORDER BY SAL DESC
SQL> /
SAL
----------
5000
3000
3000
2975
2850
2450
6 rows selected.
Q. WAQTD annual sal if the employees are getting some sal arrange the op in
ascending order.
Q. WAQTD max sal, min sal in each dept if they are getting some sal and order the
max sal in descending order.
===================================================================================
================================================================