Select Examples Oracle

CONVENTIONAL SELECT

SQL> SELECT JOB_GRADE,EMP_NAME from employee;

JOB_GRADE            EMP_NAME
-------------------- --------------------
BOFH                 Peter
BOFH                 David
BOSS                 Ramon
MANAGER              Onin
GOD                  Xesar

ALIAS :

SQL> SELECT JOB_GRADE as CARGO,EMP_NAME from employee;

CARGO                EMP_NAME
-------------------- --------------------
BOFH                 Peter
BOFH                 David
BOSS                 Ramon
MANAGER              Onin
GOD                  Xesar

SQL>

ORDER BY

SQL> SELECT EMP_NO,JOB_GRADE as CARGO,EMP_NAME from employee ORDER BY EMP_NO;

    EMP_NO CARGO                EMP_NAME
---------- -------------------- --------------------
         1 BOFH                 David
         2 BOSS                 Ramon
         3 MANAGER              Onin
         4 GOD                  Xesar
         5 BOFH                 Peter

SQL>

WHERE CONDITION:

SQL> SELECT EMP_NO,JOB_GRADE as CARGO,EMP_NAME from employee WHERE EMP_NO>'2' OR
DER BY EMP_NO;

    EMP_NO CARGO                EMP_NAME
---------- -------------------- --------------------
         3 MANAGER              Onin
         4 GOD                  Xesar
         5 BOFH                 Peter

SQL>

Number comparision: '=', o '<', o'>', o'<=', o '>=', 'between … and …'.
Strings comparision: 'like'. you can use '%' as "*" too

A very crazy comparision:

SQL> select EMP_NO,JOB_GRADE FROM employee where EMP_NO<=2 OR EMP_NAME='Peter';
    EMP_NO JOB_GRADE
---------- --------------------
         5 BOFH
         1 BOFH
         2 BOSS
SQL>SQL> select EMP_NAME,EMP_NO,JOB_GRADE FROM employee where EMP_NO<=2 OR EMP_NAME=
'%r%';

EMP_NAME                 EMP_NO JOB_GRADE
-------------------- ---------- --------------------
David                         1 BOFH
Ramon                         2 BOSS

SQL>