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

SQL Functions

The document describes various single row functions in Oracle including character, numeric, date, and conversion functions. Character functions change the case or extract parts of text like UPPER, LOWER, SUBSTR, and INSTR. Numeric functions perform calculations on numbers like ROUND and TRUNC. Date functions manipulate dates like ADD_MONTHS and MONTHS_BETWEEN. Conversion functions change the format of data between text, numbers and dates like TO_CHAR, TO_NUMBER and TO_DATE.

Uploaded by

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

SQL Functions

The document describes various single row functions in Oracle including character, numeric, date, and conversion functions. Character functions change the case or extract parts of text like UPPER, LOWER, SUBSTR, and INSTR. Numeric functions perform calculations on numbers like ROUND and TRUNC. Date functions manipulate dates like ADD_MONTHS and MONTHS_BETWEEN. Conversion functions change the format of data between text, numbers and dates like TO_CHAR, TO_NUMBER and TO_DATE.

Uploaded by

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

SINGLE ROW FUNCTIONS

1. CHARACTER FUNCTIONS:
UPPER:
select upper(name) from emp;

LOWER:
select lower(name) from emp;

INITCAP:
select initcap(name) from emp;

LENGHT:
select length(name) from emp;

SUBSTR:

select substr(name,2,4) from emp; [Saqib to aqib]


INSTR:

select instr(name,’a’) from emp; [Saqib to 1]


LPAD:

select lpad(name,10,’*’) from emp; [Saqib Saleem to *****Saqib]


RPAD:

select rpad(name,10,’*’) from emp; [Saqib Saleem to Saqib*****]


2. NUMERIC FUNCTIONS:
ROUND:

select round(average,3) from emp; [199.9966 to 199.997]


select round(average) from emp; [199.9966 to 200]
TRUNC:

select trunc(average,3) from emp; [199.9966 to 199.996]


MOD:

select mod(15,4) from dual; [3]


3. CHARACTER FUNCTIONS:

ADD_MONTHS:

select add_months(month,3) from emp; [02/JAN/98 to 02/APR/1998]


MONTHS_BETWEEN:

select months_between(sysdate,hiredate) from emp; [month between both dates]


LAST_DAY:

select last_day(sysdate) from dual; [last day of current month]

4. CONVERSION FUNCTIONS:
TO_CHAR:

Select TO_CHAR(date,’DD-MON-YYYY’) from emp; [02/JAN/98 to 02-JAN-1998]


Select TO_CHAR(salary,’999,999,999.00’) from emp; [24000 to 24,000.00]
Select TO_CHAR(date,’MON’)=’JAN’ from emp; [all JAN month data]
TO_NUMBER:
select to_number(substr(hiredate,1,2)) from emp;

TO_DATE:
select to_date('10-11-20','mm-dd-yy') from dual;

You might also like