Oracle SQL Functions
Oracle SQL Functions
By PenchalaRaju.Yanamala
(4).Round the number to the nearest higher integer, if it has got any
Decimal place? {CEIL (NUM)}
(7).Find out the square root of the given number? {SQRT (NUM)}
(8).Find out the Nth power of the given number? {POWER (NUM)}
(9). Find out the greatest value from the given list of Numbers? {GREATEST
(N)}
A: - SQL> select GREATEST (54, 89, 65) from dual;
(10).find out the least value from the given list of numbers? {LEAST (NUM)}
(11).find out the status of the given list of numbers? {SIGN (NUM)}
(12).Replace the null values in the specified column with the Specified
value
List of numbers? {NVL (column n)}
A: - SQL> select NVL (comm, 0) from EMP;
(13).Find the maximum value of the column in the given set of Rows?
{MAX (c n)}
A: - SQL> select MAX (Sal) from EMP;
(14).Find the minimum value of the column in the given set of Rows?
{MIN (c n)}
A: - SQL> select MIN (Sal) from EMP;
(21). Find the ASCII code for the given ASCII Character? {ASCII (St)}
(22).Find the equivalent ASCII character for the given ASCII Code?
{CHR (num)}
A: - SQL> select CHR (65) from Dual;
(24).find the position of the specified part of the string? {INSTR (st)}
{INSTR (Var2)}
A: - SQL> select INSTR (‘MANAGER’, ‘A’, 1, 2) from Dual;
(29).Remove the specified char(s) from the extreme left side of the
given string LTRIM (st), LTRIM (Var2)
(33).Replace set1 completely with set2 in the given string? REPLACE (var2)
(35). Match the char, strings, those spell differently but sounds alike.
SOUNDEX(),SOUNDEX (var2)
A: - SQL> select ename From EMP where soundex (ename) = soundex
(‘SMITH’);
(36). Find the no of months between the given two date values?
MONTHS_BETWEEN(date1, date2)
(38).find the date of ‘day’ (2nd parameter) after the date (1st parameter)?
NEXT_DAY (date, day)
A: - SQL> select NEXT_DAY (’14-JAN-05’,’WED’) from Dual;
(39).find out the most recent date form the given list of date Values?
GREATEST (date1, date2…)
A: - SQL> select GREATEST (’14-JAN-05’, ’14-JAN-03’) from Dual;
(40).find out the oldest date form the given list of date Values? LEAST
(date1, date2…)
A: - SQL> select LEAST (’14-JAN-05’, ’14-JAN-03’) from Dual;
(41).find the operating system date and time. (No parameters are
Required SYSDATE ())
(42).Converts any date value to a char value in the specified Format as well
as to convert number into character? TO_CHAR (date)
44. TO_NUMBER ()
45. HEXTORAW ()
46. RAWTOHEX ()
47. CHARTOROWID ()
48. ROWIDTOCHAR ()
56. Find the First occurance of character 'a' from the following string i.e
'Computer Maintenance Corporation'?
SQL>SELECT INSTR('Computer Maintenance Corporation','a',1) FROM DUAL;
63. Display the maximum salary being paid to depart number 20?
SQL>select max(sal) from emp where deptno=20;
70. Display the following output for each row from emp table?
“scott has joined the company on wednesday 13th August ninten ninety”
SQL>select ENAME||' HAS JOINED THE COMPANY ON '||
to_char(HIREDATE,'day
ddth Month year') from EMP;
71. Display the common jobs from department number 10 and 20?
SQL>select job from emp where deptno=10 and job in(select job from emp
where deptno=20);