Dbms
Dbms
15 rows selected.
SQL> SELECT 'The job title ' || INITCAP(ename) || ' is ' || LOWER(job) AS "EMPLOYEE
2 DETAILS" FROM emp;
EMPLOYEE
DETAILS
-------------------------------------
The job title Smith is clerk
The job title Allen is salesman
The job title Ward is salesman
The job title Jones is manager
The job title Martin is salesman
The job title Blake is manager
The job title Clark is manager
The job title Scott is analyst
The job title King is president
The job title Turner is salesman
The job title Adams is clerk
EMPLOYEE
DETAILS
-------------------------------------
The job title James is clerk
The job title Ford is analyst
The job title Miller is clerk
The job title Nida is clerk
15 rows selected.
15 rows selected.
EMPNO MONTH
---------- -----
7698 05/81
ENAME HIREDATE
---------- ---------------------------------------------
SMITH 17 December, 1980
ALLEN 20 February, 1981
WARD 22 February, 1981
JONES 2 April, 1981
MARTIN 28 September, 1981
BLAKE 1 May, 1981
CLARK 9 June, 1981
SCOTT 9 December, 1982
KING 17 November, 1981
TURNER 8 September, 1981
ADAMS 12 January, 1983
ENAME HIREDATE
---------- ---------------------------------------------
JAMES 3 December, 1981
FORD 3 December, 1981
MILLER 23 January, 1982
Nida 26 February, 2004
15 rows selected.
ENAME HIREDATE
---------- --------
SMITH 12:00:00
ALLEN 12:00:00
WARD 12:00:00
JONES 12:00:00
MARTIN 12:00:00
BLAKE 12:00:00
CLARK 12:00:00
SCOTT 12:00:00
KING 12:00:00
TURNER 12:00:00
ADAMS 12:00:00
ENAME HIREDATE
---------- --------
JAMES 12:00:00
FORD 12:00:00
MILLER 12:00:00
Nida 12:00:00
15 rows selected.
SALARY
--------
$3,000
ENAME HIREDATE
---------- ---------
WARD 22-FEB-81
ENAME NVL(TO_CHAR(MGR),'NOMANAGER')
---------- ----------------------------------------
KING No Manager
6 rows selected.
SQL> SELECT AVG (SAL), MIN(SAL), MAX(SAL), COUNT(*)
2 FROM EMP;
MIN(HIRED MAX(HIRED
--------- ---------
17-DEC-80 26-FEB-04
COUNT(*)
----------
6
COUNT(COMM)
-----------
4
AVG(NVL(COMM,0))
----------------
146.666667
SQL> SELECT ename, 'not receive commission' as comm from emp where NVL(comm,
2 NULL) is NULL;
ENAME COMM
---------- ----------------------
SMITH not receive commission
JONES not receive commission
BLAKE not receive commission
CLARK not receive commission
SCOTT not receive commission
KING not receive commission
ADAMS not receive commission
JAMES not receive commission
FORD not receive commission
MILLER not receive commission
Nida not receive commission
11 rows selected.
DEPTNO AVERAGE_SALARY
---------- --------------
30 1566.66667
20 1945.83333
10 2916.66667
SQL>
SQL> SELECT deptno, job, sum(sal)
2 FROM emp
3 GROUP BY deptno, job;
10 rows selected.
JOB PAYROLL
--------- ----------
ANALYST 6000
MANAGER 8275
MAX(AVG(SAL))
-------------
2916.66667
SQL> spool off;