How to use SELECT Command in SQL
How to use Select in SQL
--====================================================
-- 1. simple select :- to show table data.
--====================================================
desc XX_EMP
select * from XX_EMP
select
EMPNO,
ENAME,
DEPTNO,
SAL from XX_EMP
desc XX_DEPT
--====================================================
--2. cartesian
product , Table Alise
--====================================================
select * from XX_EMP A, XX_DEPT B
--====================================================
--3. Relation or join to skip Cartesian product
--====================================================
no of table n = 2
actual no of
joins:- (n-1) = 2-1 = 1
select *
from XX_EMP A, XX_DEPT B
where A.DEPTNO
= B.DEPTNO
--====================================================
--4. Column AS
--====================================================
select
EMPNO||' - '||ENAME
AS "Imployee_Info"
from XX_EMP A, XX_DEPT B
where A.DEPTNO
= B.DEPTNO
select A.EMPNO, A.ENAME, B.* from XX_EMP A, XX_DEPT B
where A.DEPTNO
= B.DEPTNO
--====================================================
--5. Show row number
--====================================================
select ROWNUM S_No
, A.* from XX_EMP A
--====================================================
--6. count(*) show total no of records
--====================================================
select COUNT(*) AS "No
of Records" from XX_EMP
--====================================================
--7. arithmatic opertaion in select
--====================================================
select
EMPNO ,
ENAME, sal, (( sal
*10)/100) AS "Employee
Convenience"
from XX_EMP A, XX_DEPT B
where A.DEPTNO
= B.DEPTNO
--====================================================
--8. Distinct
function use
--====================================================
select Distinct
DEPTNO from XX_EMP
select Distinct
DEPTNO from XX_DEPT
--====================================================
--9. Same Column name use only Once Ex:-
DEPTNO
--====================================================
select * from XX_EMP A, XX_DEPT B
where A.DEPTNO
= B.DEPTNO
Comments
Post a Comment