You are on page 1of 16

SQL> cl scr SQL> SELECT Deptno, AVG(Sal) 2 FROM Emp 3 GROUP BY Deptno; DEPTNO AVG(SAL) ---------- ---------10 2916.

66667 20 2175 30 1675 SQL> ed Wrote file afiedt.buf 1 SELECT Deptno, MAX(AVG(Sal)) 2 FROM Emp 3* GROUP BY Deptno SQL> / SELECT Deptno, MAX(AVG(Sal)) * ERROR at line 1: ORA-00937: not a single-group group function SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT MAX(AVG(Sal)) FROM Emp GROUP BY Deptno /

MAX(AVG(SAL)) ------------2916.66667 SQL> cl scr SQL> @C:\Demobld7 ystem32\cmd.exe /c cls Table dropped. Table dropped. Table dropped. Table dropped. Table dropped. Table dropped. Table dropped.

Table dropped. Table dropped. Table dropped. View dropped. Sequence dropped. Sequence dropped. Sequence dropped. Table created. 1 row created. 1 row created. 1 row created. 1 row created. Table created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. Table created. Table created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. Table created. 1 row created. Table created. Table created. Table created. Table created.

Table created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. Index created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created. 1 row created.

1 row created. 1 row created. 1 row created. Sequence created. Sequence created. Sequence created. View created. Recyclebin purged. SQL> cl scr SQL> SELECT SUM(SUM(Sal)) 2 FROM Emp 3 GROUP BY Deptno; SUM(SUM(SAL)) ------------29025 SQL> SELECT SUM(Sal) FROM Emp; SUM(SAL) ---------29025 SQL> cl scr SQL> SELECT 2 GREATEST('HARRY', 'HARRIOT') 3 FROM DUAL; GREAT ----HARRY SQL> cl scr SQL> SELECT USER, UID 2 FROM DUAL; USER UID ------------------------------ ---------SCOTT 57

SQL> cl scr SQL> SELECT 2 USERENV('ISDBA') 3 FROM DUAL; USEREN -----FALSE SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT USERENV('LANGUAGE') FROM DUAL /

USERENV('LANGUAGE') ---------------------------------------------------AMERICAN_AMERICA.WE8MSWIN1252 SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT USERENV('TERMINAL') FROM DUAL /

USERENV('TERMINA ---------------NIT SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT USERENV('SESSIONID') FROM DUAL /

USERENV('SESSIONID') -------------------18593 SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT USERENV('LANG') FROM DUAL /

USERENV('LANG') ---------------------------------------------------US SQL> cl scr

SQL> SELECT VSIZE(&Gnum) 2 FROM DUAL; Enter value for gnum: 1 VSIZE(1) ---------2 SQL> / Enter value for gnum: 345 VSIZE(345) ---------3 SQL> / Enter value for gnum: 24 VSIZE(24) ---------2 SQL> / Enter value for gnum: 2345 VSIZE(2345) ----------3 SQL> cl scr SQL> SELECT 2 Ename||' is Occupying '||VSIZE(Ename)||' Bytes of Memory 3 FROm Emp; ERROR: ORA-01756: quoted string not properly terminated SQL> ed Wrote file afiedt.buf 1 2 3* SQL> SELECT Ename||' is Occupying '||VSIZE(Ename)||' Bytes of Memory' FROm Emp /

ENAME||'ISOCCUPYING'||VSIZE(ENAME)||'BYTESOFMEMORY' -------------------------------------------------------------------------------KING is Occupying 4 Bytes of Memory BLAKE is Occupying 5 Bytes of Memory CLARK is Occupying 5 Bytes of Memory JONES is Occupying 5 Bytes of Memory MARTIN is Occupying 6 Bytes of Memory ALLEN is Occupying 5 Bytes of Memory TURNER is Occupying 6 Bytes of Memory JAMES is Occupying 5 Bytes of Memory WARD is Occupying 4 Bytes of Memory FORD is Occupying 4 Bytes of Memory SMITH is Occupying 5 Bytes of Memory

ENAME||'ISOCCUPYING'||VSIZE(ENAME)||'BYTESOFMEMORY' -------------------------------------------------------------------------------SCOTT is Occupying 5 Bytes of Memory ADAMS is Occupying 5 Bytes of Memory MILLER is Occupying 6 Bytes of Memory 14 rows selected. SQL> cl scr SQL> SELECT 2 Ename||' You Are Occupying '||TO_CHAR(TO_DATE(VSIZE(Ename), 'J'), 'JSP')||' Bytes of Memory Space.' Ename 3 FROM Emp; ENAME -------------------------------------------------------------------------------KING You Are Occupying FOUR Bytes of Memory Space. BLAKE You Are Occupying FIVE Bytes of Memory Space. CLARK You Are Occupying FIVE Bytes of Memory Space. JONES You Are Occupying FIVE Bytes of Memory Space. MARTIN You Are Occupying SIX Bytes of Memory Space. ALLEN You Are Occupying FIVE Bytes of Memory Space. TURNER You Are Occupying SIX Bytes of Memory Space. JAMES You Are Occupying FIVE Bytes of Memory Space. WARD You Are Occupying FOUR Bytes of Memory Space. FORD You Are Occupying FOUR Bytes of Memory Space. SMITH You Are Occupying FIVE Bytes of Memory Space. ENAME -------------------------------------------------------------------------------SCOTT You Are Occupying FIVE Bytes of Memory Space. ADAMS You Are Occupying FIVE Bytes of Memory Space. MILLER You Are Occupying SIX Bytes of Memory Space. 14 rows selected. SQL> cl scr SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10 11 12 COLUMN Empno FORMAT 99 COLUMN Ename FORMAT 99 COLUMN Deptno FORMAT 99 COLUMN Job FORMAT 99 COLUMN MGR FORMAT 99 COLUMN Sal FORMAT 99 COLUMN Comm FORMAT 99 COLUMN HireDate FORMAT 99 COLUMN Total FORMAT 999 SELECT SUM(VSIZE(Empno)) Empno, SUM(VSIZE(Ename)) Ename, SUM(VSIZE(Deptno)) Deptno, SUM(VSIZE(Job)) Job, SUM(VSIZE(MGR)) MGR, SUM(VSIZE(Sal)) Sal, SUM(VSIZE(Comm)) Comm, SUM(VSIZE(HireDate)) HireDate, SUM(VSIZE(Empno)) + SUM(VSIZE(Ename)) + SUM(VSIZE(Deptno)) +

13 14 15 16 17 18

SUM(VSIZE(Job)) + SUM(VSIZE(MGR)) + SUM(VSIZE(Sal)) + SUM(VSIZE(Comm)) + SUM(VSIZE(HireDate)) Total FROM Emp;

EMPNO ENAME DEPTNO JOB MGR SAL COMM HIREDATE TOTAL ----- ----- ------ --- --- --- ---- -------- ----41 70 28 96 39 34 7 98 413 SQL> cl scr SQL> 2 3 4 SELECT Ename, Sal, Job FROM Emp WHERE Job = 'manager';

no rows selected SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE LOWER(Job) = 'manager' / SAL --### ### ### JOB --------MANAGER MANAGER MANAGER

ENAME ---------BLAKE CLARK JONES

SQL> COLUMN Sal FORMAT 9999 SQL> / ENAME ---------BLAKE CLARK JONES SAL ----2850 2450 2975 JOB --------MANAGER MANAGER MANAGER

SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE Job = UPPER('manager') / SAL ----2850 2450 2975 JOB --------MANAGER MANAGER MANAGER

ENAME ---------BLAKE CLARK JONES SQL> ed

Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE Job = 'MANAGER' / SAL ----2850 2450 2975 JOB --------MANAGER MANAGER MANAGER

ENAME ---------BLAKE CLARK JONES

SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE SOUNDEX(Job) = SOUNDEX('manger') / SAL ----2850 2450 2975 JOB --------MANAGER MANAGER MANAGER

ENAME ---------BLAKE CLARK JONES

SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE SOUNDEX(Job) = SOUNDEX('clrk') /

ENAME SAL JOB ---------- ----- --------JAMES 950 CLERK SMITH 800 CLERK ADAMS 1100 CLERK MILLER 1300 CLERK SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT Ename, Sal, Job FROM Emp WHERE SOUNDEX(Ename) = SOUNDEX('Smythe') /

ENAME SAL JOB ---------- ----- --------SMITH 800 CLERK SQL> SELECT Ename, SOUNDEX('SMITH'), SOUNDEX('SMYTHE') 2 FROM Emp

3 WHERE Ename = 'SMITH'; ENAME SOUN SOUN ---------- ---- ---SMITH S530 S530 SQL> cl scr SQL> SPOOL OFF

You might also like