sql function example


FUNCTION EXAMPLE:
| LOWER | (loc) |
| function | input to function |
Using LOWER sql function to convert all the location text to lower case latter
SQL> select deptno, LOWER(loc) as location from dept;
DEPTNO LOCATION
---------- -------------
10 new york
20 dallas
30 chicago
40 boston
Using UPPER sql function to convert all the location text to Upper case latter
SQL> select deptno, UPPER(loc) as location from dept;
DEPTNO LOCATION
---------- -------------
10 NEW YORK
20 DALLAS
30 CHICAGO
40 BOSTON
Using INITCAP sql function to convert and make sure the capital latter in from of the location text.
SQL> select deptno, INITCAP(loc) as location from dept;
DEPTNO LOCATION
---------- -------------
10 New York
20 Dallas
30 Chicago
40 Boston
SQL>
MORE EXAMPLE ON SQL FUNCTION:
SQL> SELECT deptno,
2 INITCAP(loc) as location,
3 LENGTH(loc) as "LOCation" from dept;
DEPTNO LOCATION LOCation
---------- ------------- ----------
10 New York 8
20 Dallas 6
30 Chicago 7
40 Boston 6
SQL> SELECT deptno as "DEPartment",
2 INITCAP(loc) as location,
3 LENGTH(loc) as "LOC Length"
4 from dept;
DEPartment LOCATION LOC Length
---------- ------------- ----------
10 New York 8
20 Dallas 6
30 Chicago 7
40 Boston 6
SQL>
- sql_command's blog
- Login or register to post comments
- 725 reads
- Email this page












