Exforsys.com
 
Home Tutorials Oracle 9i
 

Tutorial 4: SQL functions

 

Tutorial 4: SQL functions - Page 3

Page 3 of 7



RPAD(): This function is used to left pad the the given string with specified character or string.


SQL > SELECT RPAD('BILL ' , 12 , 'CLINTON') FROM DUAL;


RPAD('BILL',
------------
BILL CLINTON



LTRIM(): This function removes specified string from the given string if it is there to the left of given string.


SQL > SELECT LTRIM('GEORGE BUSH', 'GEORGE') FROM DUAL;


LTRIM
-----
 BUSH


RTRIM(): This function removes specified string from the given string if it is there to the right of given string.


SQL > SELECT RTRIM('TONY BLAIR', 'AIR') FROM DUAL;


RTRIM('
-------
TONY BL


ASCII(): Displays equivalent ASCII value of a character.
SQL > SELECT ASCII('A') FROM DUAL;


ASCII('A')
----------
        65



SQL >SELECT TRANSLATE('JOHN','H','N') FROM DUAL;


TRAN
----
JONN


OTHER FUNCTIONS:


Note: Arguments to the below given functions are in terms of radians


COS(x): It returns the Cosine of x.
SQL> SELECT COS(0) FROM DUAL;
    COS(0)
----------
         1
COSH(x) : It returns hyperbolic cosine of x.


SQL> SELECT COSH(0) FROM DUAL;


   COSH(0)
----------
         1


SIN(x) : It returns sine of x.


SQL> SELECT SIN(0) FROM DUAL;


    SIN(0)
----------
         0


SINH(x): It returns hyperbolic sine of x.


SQL> SELECT SINH(0) FROM DUAL;


   SINH(0)
----------
         0


TAN(x): It returns tangent of x.


SQL> SELECT TAN(0) FROM DUAL;


    TAN(0)
----------
         0


 


TANH(x): It returns hyperbolic tangent of x.
SQL> SELECT TANH(0) FROM DUAL;


   TANH(0)
----------
         0


 


DATE FUNCTIONS:
          
 ADD_MONTHS(date, n) : Adds n months to the specified date .


  SQL> SELECT  ADD_MONTHS('1-JAN-05',5) FROM DUAL;


  ADD_MONTHS
  ------------------
  01-JUN-05


LAST_DAY(date): Gives last date of the specified month (date).


SQL> SELECT LAST_DAY('1-JAN-05') FROM DUAL;


LAST_DAY(
---------
31-JAN-05



MONTHS_BETWEEN(date1, date2): It gives difference between the two dates date1, date2 in months.


SQL>  SELECT MONTHS_BETWEEN('31-DEC-05','1-JAN-05') FROM DUAL


MONTHS_BETWEEN('31-DEC-05','1-JAN-05')
--------------------------------------
                            11.9677419


SQL>  SELECT MONTHS_BETWEEN('31-JUL-05','1-JUL-05') FROM DUAL


MONTHS_BETWEEN('31-JUL-05','1-JUL-05')
--------------------------------------
                            .967741935




Next Page: Tutorial 4: SQL functions - Page 4





 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape