Oracle Database Course – SELECT and FROM Clause

--SQL SELECT AND FROM CLAUSE SAMPLES

---SELECT * FROM <TABLE> ; 

SELECT * FROM EMP ; --14 rows , 8 columns

SELECT empno, ename from emp ; 

select 
* 
from 
hr_operating_units ; 


select distinct Name from hr_operating_units  ;

select * from emp; 

select distinct deptno,  mgr from emp ;

select empno, ename, job, mgr , sal, 12*sal as AnnualSalary from emp ; 

select empno, ename, job, mgr , sal, 12*sal  AnnualSalary from emp ; 

select empno, ename, job, mgr , sal, 12*sal  "Annual Salary" from emp ; 


select empno, ename, job, mgr , sal, 'hello' SampleText from emp ; 

----NULL Value 

select * from dual ; 

select null , 'hello'  from dual ; 

select length(null), length(' '), length(0)  from dual ; 

select * from emp ; 

--Provide a 10% additional commission for each employee as a bonus
--for employees whose commission earlier was null, give them 500

select empno, ename, job, mgr, comm, comm+comm*0.1 newcomm  from emp ; 

--- NVL --Nullvalue  NVL(col1,col2)  ---> if col1 is null, returns col2, else return col1

select nvl(null,'Hello')  , nvl('World','News'), nvl(null,null)  from dual ; 

select empno, ename, job, mgr, comm, NVL(comm*1.1,500) newcomm  from emp ; 

select NULL +null , null-null, null*null, null/null from dual; 

select NULL +null , null-null, null*null, null/null from gl_ledgers; 

select 1, sysdate, 'Char', null,Name  from gl_ledgers ; 

select * from  fnd_user ; 

select 'UserID'  || user_id ||' For User Name ' || user_name from fnd_user; 

select person_id, last_name, first_name , last_name ||'_'|| first_name as FullName 
from per_people_f ; 



desc xxemp7;

insert into xxemp7(column1) values('test')  ; 

select * from xxemp7; 

insert into xxemp7(column1) values(null)  ; 


Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Category: SQL