Aggregate Functions sql3
Aggregate Functions sql3
==>Numeric Function
1. count
2. sum
3. min
4. max
5. avg
SUM(SAGE)
----------
56
AVG(SAGE)
----------
18.6666667
SUM(SAGE)/COUNT(*)
------------------
18.6666667
MIN(SAGE)
----------
17
MAX(SAGE)
----------
20
SQL>
SYSDATE
---------
19-JUN-23
SQL> select abs(3) from dual;
ABS(3)
----------
3
ABS(-3)
----------
3
ABS(-3.6)
----------
3.6
CEIL(4.2)
----------
5
FLOOR(4.2)
----------
4
CEIL(-8.4)
----------
-8
FLOOR(-8.4)
-----------
-9
MOD(18,4)
----------
2
POWER(3,2)
----------
9
ROUND(4.2)
----------
4
ROUND(4.8)
----------
5
ROUND(4.24)
-----------
4
SIGN(244.6)
-----------
1
SIGN(-244.6)
------------
-1
SQRT(25)
----------
5
==>String functions
97
Combined St
-----------
Hello World
LENGTH('HELLO')
---------------
5
LOWER
-----
hello
UPPER
-----
HELLO
SUBSTR('HE
----------
ello World
SUBSTR
------
World
SUBST
-----
World
SUBST
-----
ello
S
-
d
SU
--
ld
SQL> select trim(' Hello World ') from dual;
TRIM('HELLOWOR
--------------
Hello World
INSTR('HELLO','E')
------------------
2
INSTR('HELLO','L')
------------------
3
SUBSTR('HEL
-----------
hello world
SUBSTR('HE
----------
ello world
S SUBSTR('HE
- ----------
h ello world
U SUBSTR('HE
- ----------
H ello world
CONCAT(UPPE
-----------
Hello world
INITCAP('HE
-----------
Hello World
REPLACE('HE
-----------
hallo world
REPLACE('HE
-----------
heaao worad
C
-
A
C
-
a
LPAD('HELL
----------
$$$$$hello
RPAD('HELL
----------
hello$$$$$
RPAD(
-----
hello
>>>Date Functions
CURRENT_D
---------
19-JUN-23
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
19-JUN-23 05.58.57.770000 PM +05:30
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
19-JUN-23 05.59.17.176000 PM +05:30
EXTRACT(YEARFROMSYSDATE)
------------------------
2023
EXTRACT(MONTHFROMSYSDATE)
-------------------------
6
EXTRACT(DAYFROMSYSDATE)
-----------------------
19
EXTRACT(HOURFROMCURRENT_TIMESTAMP)
----------------------------------
12
EXTRACT(MINUTEFROMCURRENT_TIMESTAMP)
------------------------------------
31
EXTRACT(SECONDFROMCURRENT_TIMESTAMP)
------------------------------------
35.873
LAST_DAY(
---------
30-JUN-23
LAST_DAY(
---------
31-JAN-10
NEXT_DAY(
---------
20-JUN-23
MONTHS_BETWEEN('25-JUL-2023','20-JUN-2023')
-------------------------------------------
1.16129032
MONTHS_BETWEEN('25-JUL-2023','25-JUN-2023')
-------------------------------------------
1
ADD_MONTH
---------
20-OCT-23
ADD_MONTH
---------
20-FEB-23