Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.8 kB
7
Indexable
Never
15/03/2024
=========================================================================================================

Function :-function is a block of code for reuse again again.

1:-in built function 
2: User define function 

1.In Built function:-
Upper:- convert into upper case:-
lower:- convert into lower case
length():- return length of string
trim():-removes the specified character from both side
concat():-to join two string
substring :- return substring of the string

exa:-
use testdb;

select * from customer where city = "New York";
select city from customer;
select upper(city) from customer;
select lower(city) from customer;
select length("nagpur") ;
select city,length(city) from customer;
select trim("      ram       ");
select trim("s" from "sswavses");
select concat("ra","m");
select concat(cust_name,city) as namecity  from customer;
select substr(city,2,3) from customer;
select substring(city,2,3) from customer

-----------------------------------------------------------------------------------------------------------
2.Numeric function:


select abs(30.9);
select abs(-30.6);
select sqrt(64);
select pow(3,2);
select power(3,3);
select truncate(1234.345,2);
select truncate(1234.345,1);
select truncate(1234.345,-2);

-----------------------------------------------------------------------------------------------------------------
3. Date function:
use testdb;
select sysdate();
select now();
select curdate();
select curtime();
select month("2024-03-23");

-------------------------------------------------------------------------------------------
4. aggreagate function:
count(), min(),max(),avg(),sum()
====================================================================================================================================
Leave a Comment