By admin | January 25, 2008
Remember ORDER BY is the last clause in the SELECT statement, which arranges the order after the SQL data are fetched
The ORDER BY clause arranges the output of a SELECT statement in a particular order. It can be ascending or descending.
SELECT EMPNO,ENAME,SAL FROM EMP ORDER BY SAL;
The above SQL will display the result in the [...]
By admin | January 25, 2008
This lesson will describe the usage of IN, Between Operators in Oracle
At times usage of OR, AND becomes cumbersome. Oracle has facilitated some other operators
BETWEEN
SELECT ENAME,JOB,SAL FROM EMP
WHERE SAL BETWEEN 1500 AND 3000;
is exactly equivalent to
SELECT ENAME,JOB,SAL FROM EMP
WHERE SAL> 1500 AND SAL < 3000;
Between can replace complicated AND operators
IN
SELECT EMPNO,ENAME,JOB,DEPTNO FROM EMP
WHERE JOB IN [...]
By admin | January 25, 2008
How to and where to use AND and OR Operators in Select Statement
We should remember a fundamental concept. AND restricts further and OR loosens the restrictions in the result set
SELECT ENAME, SAL FROM EMP WHERE DEPTNO=10 AND SAL>1500;
The above statement will display the restricted set of rows whose department no is 10 and SAL is [...]
By admin | January 25, 2008
How to handle date values in Oracle
SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL FROM EMP
WHERE HIREDATE <’01-JUN-81’;
Date is treated as literals
By admin | January 25, 2008
How to embed a message in SQL
SELECT ENAME||’ ‘||’is in the position of ’||’ ‘||JOB||’ ‘||’and his earning is || ‘ ‘||SAL “Employee Details” FROM EMP;
Look at the usage of quodes (’) and the concatination symbols ||
The blank spaces have been mentioned within quodes to display the required additional blanks between words.
[...]
By admin | January 25, 2008
How to use an aliase name in the SELECT clause in Oracle
However, instead of ename and job the column headings should be empname and jobrole. The query that will solve our purpose will be:
SELECT ENAME EMPNAME, JOB JOBROLE FROM EMP;
The fun comes, if you want a space in between. Like if you want JOBROLE should [...]
By admin | January 25, 2008
NULL in Oracle means empty. You need really a special mechanism to handle NULL values in Oracle
Oracle supoorts the NVL function to handle NULL values.
NULL means empty, so it is neither zero nor spaces. NULL value takes place, when the user does not enter any data in the respective columns.
So, if you encounter a null [...]