Académique Documents
Professionnel Documents
Culture Documents
S 1041888
1. Write a query using built-in function to round-off a number to nearest whole number.
SQL> select round(45.34,0) from dual; ROUND(45.34,0) -------------45
2. Write a query using built-in function to find the absolute value of a number.
SQL> select abs(-34) from dual; ABS(-34) ---------34
3. Write a query using built-in function to retain the decimal part and truncate the fractional part in a number.
SQL> select trunc(234.543,0) from dual; TRUNC(234.543,0) ---------------234
4. Write a query using built-in function to find the remainder as a result of division
5. Write a query using built-in function to find the sign of a value without its magnitude.
SQL> select sign(-543) from dual; SIGN(-543) ----------1
6. Write a query using built-in function to find the value of a number m raised to power n.
SQL> select power(5.4,3) from dual; POWER(5.4,3) -----------157.464
7. Write a query using built-in function to find the square root of a number.
SQL> select sqrt(.25) from dual; SQRT(.25) ---------.5
8. Write a query using built-in function to round off a number to the nearest integer with respect to the decimal places.
SQL> select round(32.543) from dual; ROUND(32.543) ------------33
10. Write a query using built-in function to accept a character/ column of characters as input and return as output the initial character in uppercase.
SQL> select initcap('welcome') from dual; INITCAP ------Welcome
11. Write a query using built-in function to accept a character/ column of characters as input and return as output in uppercase and lowercase.
SQL> select upper('welcome'),lower('HOME') from dual; UPPER(' LOWE ------- ---WELCOME home
13. Write a query using built-in function to find character equivalent of a number.
SQL> select chr(57) from dual; C 9
14. Write a query using built-in function to left pad and right pad a string with *.
SQL> select lpad('Hi',10,'*'),rpad('friend',10,'*') from dual; LPAD('HI', ---------********Hi RPAD('FRIE ---------friend****
15. Write a query using built-in function to perform right and left trim of a string.
SQL> select ltrim(' hey'),rtrim('friend ') from dual;
LTR --hey
RTRIM( -----friend
16. Write a query using built-in function to extract specified number of characters from a string.
17. Write a query using built-in function to return the length of a string up to the first occurrence of the character specified.
SQL>select instr('nivetha','i') from dual; INSTR('NIVETHA','I') -------------------2
18. Write a query using built-in function to find the ascii equivalent of a character given as input.
SQL> select ascii('N') from dual; ASCII('N') ---------78
19. Write a query using built-in function to find the length of a string/ group of string given as input.
SQL> select length('Nandhini') from dual; LENGTH('NANDHINI') -----------------8
20. Write a query using built-in function to extract specified number of characters and replace with new characters from specified string
21. Write a query using built-in function to replace a particular character in a string by a particular character.
SQL> select replace('head','a','r') from dual; REPL ---herd
23. Write a query using built-in function to increase a particular/ group of date by number of months specified.
SQL> select add_months('01-jul-1993',6) from dual; ADD_MONTH --------01-JAN-94
24. Write a query using built-in function to find the last date of the month in the particular date specified.
LAST_DAY( --------29-FEB-12
25. Write a query using built-in function to find the number of months between two date.
SQL> select months_between('03-feb-2012','01-jul-2011') from dual; MONTHS_BETWEEN('03-FEB-2012','01-JUL-2011') ------------------------------------------7.06451613
26. Write a query using built-in function to round off a particular date to the next month that follows.
SQL> select round(sysdate,'mon') from dual; ROUND(SYS --------01-FEB-12
27. Write a query using built-in function to round off the date to the nearest Sunday.
SQL> select round(sysdate,'dy')from dual;
ROUND(SYS --------05-FEB-12
RESULT : Hence, the SQL queries are written using Built-in functions.