0% found this document useful (0 votes)
8 views

SQL - Single Function01

Uploaded by

manjari sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

SQL - Single Function01

Uploaded by

manjari sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Functions

dual - dummy - global temporary table

Character -

Number

Date

Null

Misc

Conversion

functions will always come with bracket and within bracket one will write the
arguments

arguments - column names / expression /another function

upper('manjari')

Character

Case
upper()
lower()
initcap()

Charcater

concat()
length()
substr()
instr()
lpad/rpad()
trim()
replace()

Number

round()
trunc()
mod()

Date

day_between()
add_months()
next_day()
last_day()
trunc()
round()
Null

nvl()
nvl2()
nullif()
coalesce()

Misc

Case
Decode()

select * from dual;

select 1+2 from dual;

select 'manjari'||'Sri' from dual;

select 145*234 from dual;

select 1234+3435 from employees

select sysdate from dual

select systimestamp from dual

select currentdate from dual - other softwares

select upper('manjari prakash') from dual

select lower('MANJARI PRAKash') from dual

select initcap('manjari prakash') from dual

select first_name,last_name
from employees
where upper(last_name)='GRANT'

select upper(first_name),upper(last_name)
from employees
where upper(last_name)='GRANT'

select * from city


where lower(name) like '%bo%'

select upper(last_name) as last_name from employees

select concat('manjari',' srivastava') from dual

select concat(city,state_province) from locations

select first_name,length(first_name)
from employees

select length('manjari Prakash') from dual


substr(expression/col name, starting pos, number of characters)

3rd argument( number of characters) is optional

select substr('manjari',1,3) from dual

select substr('manjari',4,3) from dual

select substr('manjari',-1,3) from dual

select substr('manjari',-5,3) from dual

select substr('manjari',-4) from dual

select substr('manjari',2) from dual

select job_id from employees


where substr(job_id,4)='MAN'

instr (expr/colname,which expression looking for, starting pos, number of the


occurence)

4th argument(number of the occurence) is optional

select instr ('manjari','a',1) from dual

select instr ('manjari','a',3) from dual

select instr ('manjari','a',-1) from dual

select instr ('manjari','a',-4) from dual

select instr ('it is a beautiful world, is having lot of colours. Beauty is


relative','is',1) from dual

select instr ('it is a beautiful world, is having lot of colours. Beauty is


relative','is',1,2) from dual

select instr ('manjari','a',1,2) from dual

select instr ('it is a beautiful world, is having lot of colours. Beauty is


relative','is',-1,3) from dual

select instr ('it is a beautiful world, is having lot of colours. Beauty is


relative','is',1,4) from dual

select first_name,instr(first_name,'e',1,2) from employees

lpad/rpad (exp/col name which you want to pad ,how many character,'expression with
which you want to pad')

select lpad(salary,10,'*') from employees

select lpad(salary,10,' ') from employees


select rpad(salary,3,'$') from employees

select rpad(salary,5,'0') from employees


select salary,length(salary) from employees

select salary,length(salary),lpad('*',length(salary),'*') from employees

select salary,length(salary),lpad(' ',length(salary)+1,'*') from employees

select first_name,length(first_name),rpad('#',length(first_name),'#') from


employees

select trim('o' from 'helloooooo') from dual

select trim('h' from 'helloooooo') from dual

select trim('l' from 'helloooooo') from dual

select trim(' ' from ' manjari prakash ') from dual

select replace ('jack n jue','j','bl') from dual

You might also like