0% found this document useful (0 votes)
25 views5 pages

Class-10th-8th June

Single row functions (SRFs) operate on a single row and column and return a single result. There are 32 SRFs but 16 are commonly used including CONCAT, INITCAP, INSTR, LENGTH, LOWER, LAST_DAY, MOD, MONTHS_BETWEEN, NVL, REVERSE, REPLACE, ROUND, SUBSTR, TRUNC, TO_CHAR, and UPPER. SRFs perform various string and numeric manipulations like concatenating strings, finding string positions, converting case, rounding numbers, and converting dates to strings.
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)
25 views5 pages

Class-10th-8th June

Single row functions (SRFs) operate on a single row and column and return a single result. There are 32 SRFs but 16 are commonly used including CONCAT, INITCAP, INSTR, LENGTH, LOWER, LAST_DAY, MOD, MONTHS_BETWEEN, NVL, REVERSE, REPLACE, ROUND, SUBSTR, TRUNC, TO_CHAR, and UPPER. SRFs perform various string and numeric manipulations like concatenating strings, finding string positions, converting case, rounding numbers, and converting dates to strings.
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/ 5

-->Single Row Functions:-(SRF)

*It we give single/one input to SRF,finally we get only Single/one output.


*If we give multiple inputs to SRF, finally we get Multiple Outputs.
*.'. Number of Inputs is equals to number of Outputs.
*We have totally 32-types of SRF.
*In which 16-types are maily used.

-->Types of SRF:-[C I2 L3 M2 N R3 S T2 U]

1)CONCAT()
2)INITCAP()
3)INSTR()
4)LENGTH()
5)LOWER()
6)LAST_DAY()
7)MOD()
8)MONTHS_BETWEEN()
9)NVL(Null value Logic)
10)REVERSE()
11)REPLACE()
12)ROUND()
13)SUBSTR()
14)TRUNC()
15)TO_CHAR()
16)UPPER()

1)CONCAT():-
*It is used to "merge the two strings'.

Syntax:-
CONCAT('STR1','STR2')

EX:- WAQDT TO MERGE THE 2-STRINGS USING SRIMAN AND NARAYANA


SELECT CONCAT('SRIMAN','NARAYANA')
FROM DUAL;//SRIMANNARAYANA

2)INITCAP():-
*It is used to convert the given string's 1st letter into 'Uppercase'.

Syntax:-
INITCAP('STR')

EX:- ganga
SELECT INITCAP('ganga')
FROM DUAL;//Ganga

3)INSTR():-
*It is used to find the position of the string from the given original string.

Syntax:-
INSTR('ORIGINAL_STR','STR',POSITION[,OCCURANCE])

EX:- B A N A N A
1 2 3 4 5 6 (POSITION)

1)INSTR('BANANA','A',1,1)=2 pos
2)INSTR('BANANA','A',1,2)=4 pos
3)INSTR('BANANA','A',1,3)=6 pos
4)INSTR('BANANA','N',1,1)=3 pos
5)INSTR('BANANA','N',1,2)=5 pos
6)INSTR('BANANA','A',2,2)=6 pos

.'.SELECT COL NAME/EXP


FROM DUAL;

4)LENGTH():-
*It is used to find the number of characters present in the given string.

Syntax:-
LENGTH('STR')
ex:- SRIMANNARAYANA

SELECT LENGTH('SRIMANNARAYANA')
FROM DUAL;//

5)LOWER():-
*It is used to convert the given string into 'Lower case'.

Syntax:-
LOWER('STR')
EX:-SRIMANNARAYANA
SELECT LOWER('SRIMANNARAYANA')
FROM DUAL;//srimannarayana

6)LAST_DAY():-
*It is used to find the last date of the month from the given date.

Syntax:-
LAST_DAY('DATE'/SYSDATE)
EX:- '27-FEB-2023'
SELECT LAST_DAY('27-FEB-2023')
FROM DUAL;//TUESDAY

7)MOD():-
*It is used to get the reminder value of given 2-numbers.

Syntax:-
SELECT MOD(N1,N2)
FROM DUAL;
EX:- 1)MOD(8,3)//2
2)MOD(10,3)//1

8)MONTHS_BETWEEN():-
*It is used to find the number of months present between the given two dates.

Syntax:-
Months_Between('Date1','Date2');
ex:-
SELECT Months_Between('14-FEB-2023','14-NOV-2023')
FROM DUAL;

9)NVL():-
*It stands for NULL VALUE LOGIC.
*It is used to 'eliminate the side effects by using 'Arithmatic Operator'.

Syntax:-
SELECT NVL(ARG1,ARG2)
FROM EMP;
EX:- SELECT SAL+NVL(COMM,0)
FROM EMP;
ENAME SAL COMM RESULTS
A 10 0 10+0=10
B 20 2 20+2=22
C 30 - 30+0=30
D 40 4 40+4=44

10)REVERSE():-
*It is used to convert the given string into 'Reverse Mode'.

Syntax:- SELECT REVERSE('STR')


FROM DUAL;
EX:- BALAJI
S.REVERSE('BALAJI')
F.DUAL;//IJALAB

11)REPLACE():-
*It is used to convert the string by new string from the given original string.

Syntax:-
SELECT REPLACE('ORIGINAL_STR','STR','NEW STR')
FROM DUAL;

-->( TO REPLACE WITH SINGLE STRING VALUE)


EX:-1 AMRUTH
SELECT REPLACE('AMRUTH','M','N')
FROM DUAL;//ANRUTH

-->( TO REPLACE WITH ENTIRE STRING VALUE)


EX:-2 AMRUTH
SELECT REPLACE('AMRUTH','AMRUTH','AMMU')
FROM DUAL;//AMMU

-->( TO REPLACE WITH SINGLE STRING VALUE)


EX:-3 SAJID
SELECT REPLACE('SAJID','J','H')
FROM DUAL;//SAHID

( TO REPLACE WITH ENTIRE STRING VALUE)


EX:-4 SAJID
SELECT REPLACE('SAJID','SAJID','SHOIB')
FROM DUAL;//SHOIB

12)ROUND():-
*It is used to 'Round off' the given number based on the scale value.

Syntax:- ROUND(NUMBER[,SCALE]);

EX:-ROUND(7.4)=7
ROUND(7.5)=8
ROUND(7.9)=8
ROUND(9.2222)=9
ROUND(8.44444,3)=8.444
ROUND(8.66666,3)=8.667
.'. SELECT COL_NAME/EXP
FROM DUAL;

13)SUBSTR():-
*It is used to extract the part of string from the given original string.

Syntax:- SUBSTR('ORIGINAL_STR',POSITION[,LENGTH])

-9 -8 -7 -6 -5 -4 -3 -2 -1 (LENGTH)
EX:- B A N G A L O R E
1 2 3 4 5 6 7 8 9 (POSITION)

1)SUBSTR('BANGALORE',1,3)=B A N
2)SUBSTR('BANGALORE',3,4)= N G A L
3)SUBSTR('BANGALORE',6)= L O R E
4)SUBSTR('BANGALORE',7,5)= O R E
5)SUBSTR('BANGALORE',6,4)= L O R E
6)SUBSTR('BANGALORE',-6,3)= G A L
7)SUBSTR('BANGALORE',-6,-3)= G N A
8)SUBSTR('BANGALORE',4,9)= G A L O R E
9)SUBSTR('BANGALORE',-3,-7)=O L A G N A B
10)SUBSTR('BANGALORE',1)=B A N G A L O R E
11)10)SUBSTR('BANGALORE',-1)= E R O L A G N A B

14)TRUNC():-
*It is similar to Round function.
*It will always gives the results based on lower value.

Syntax:- TRUNC(NUMBER[,SCALE]);

EX:-
1)TRUNC(7.8)=7
2)TRUNC(7.6)=7
3)TRUNC(8.2222,2)=8.22
4)TRUNC(8.444,3)8.444

15)TO_CHAR():-
*It is used to convert the given 'date' into String format, based on 'Format
Models'.

Syntax:- TO_CHAR(SYSDATE,'FORMAT_MODELS');

FORMAT_MODELS:-

YYYY D
YEAR HH12
YY HH24
MON MIN
MM MI
DD SEC
DAY SS

EX:- 1)
SELECT TO_CHAR(SYSDATE,'YYYY')
FROM DUAL;

2)
SELECT TO_CHAR(SYSDATE,'MON')
FROM DUAL;

3)
SELECT TO_CHAR(SYSDATE,'DAY')
FROM DUAL;

16)UPPER():-
*It is used to convert the given string into 'Upper Case'.

Syntax:-
SELECT UPPER('STR')
FROM DUAL;

EX:- srimannarayana

SELECT UPPER('srimannarayana')
FROM DUAL;//SRIMANNARAYANA
-----------------------------------------------------------------------------------
---------------

You might also like