Archive for the 'Database' Category

Arranging output in SQL

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 [...]

Between, In Operators in SQL

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 [...]

And & OR Operators in SQL

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 [...]

Handling Date Values in SQL

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

embed a message in SQL

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.