프로그램 공부 로그/DB

sql (sum, max, min, count)

HyoungJunYoon 2020. 11. 20. 18:58

table tb

index | date

  1    |  2020

  1    |  2021

  2    |  2019

 

1. sum

ex) SELECT sum(index)

from tableName

result = 3

 

2. max

ex) SELECT MAX(index)

from tableName

result = 2

 

ex) SELECT MAX(date)

from tableName

result = 2021

 

2. min

ex) SELECT MIN(index)

from tableName

result = 1

 

ex) SELECT MIN(date)

from tableName

result = 2019

 

2. count

ex) SELECT COUNT(*)

from tableName

result = 2

 

ex) SELECT COUNT(*)

from tableName

GROUP BY index

result =

2 | 1

'프로그램 공부 로그 > DB' 카테고리의 다른 글

INNER JOIN  (0) 2020.11.18
Dao에서 JDBC를 통한 DB연결  (0) 2020.11.14
sql  (0) 2020.11.10