πŸ₯•
TIL
  • [TIL] Studying tech / computer science knowledge
  • KeyMap
  • μ•Œκ³ λ¦¬μ¦˜
    • λ³΅μž‘λ„ 계산 ( Computational Complexity )
    • DisjointSet-unionFind
    • Bellman-ford Algorithm
    • Dijkstra's Algorithm
    • DP ( Dynamic Programming , 동적 κ³„νšλ²• )
    • ν”Œλ‘œμ΄λ“œ-μ›Œμ…œ μ•Œκ³ λ¦¬μ¦˜ (Floyd-Warshall algorithm)
    • Kruskal's Algorithm
    • 졜μž₯ 증가 μˆ˜μ—΄ (Longes Increasing Subsequence)
    • Prim's Algorithm
    • μ •λ ¬
    • μ‹œκ°„λ³΅μž‘λ„ 와 κ³΅κ°„λ³΅μž‘λ„ ( Time Complexity & Space Complexity )
    • Topological Sort (μœ„μƒ μ •λ ¬)
  • μ±… μ½κ³ λ‚œ ν›„ μš”μ•½
    • ν”„λ‘œκ·Έλž˜λ° λŒ€νšŒμ—μ„œ λ°°μš°λŠ” μ•Œκ³ λ¦¬μ¦˜ λ¬Έμ œν•΄κ²° μ „λž΅
    • cleancode
    • 도메인 주도 μ„€κ³„λ‘œ μ‹œμž‘ν•˜λŠ” λ§ˆμ΄ν¬λ‘œμ„œλΉ„μŠ€ 개발
    • 였브젝트
  • CDC
    • debzium
    • kafka
  • 개발 상식
    • asciidoctor
    • 컴파일러
    • ELK μŠ€νƒ
    • μ—”λ””μ•ˆ
    • git
    • Gitmoji
    • ν…ŒμŠ€νŠΈ μ’…λ₯˜
    • λΌμ΄λΈŒλŸ¬λ¦¬μ™€ ν”„λ ˆμž„μ›Œν¬
    • μ •κ·œ ν‘œν˜„μ‹
    • REST API
    • 동기와 비동기 / Blockingκ³Ό NonBlocking
    • Transaction Script와 Domain Model
    • λ””μžμΈ νŒ¨ν„΄
      • 행동 νŒ¨ν„΄
      • 객체 생성 νŒ¨ν„΄
        • 좔상 νŒ©ν† λ¦¬ νŒ¨ν„΄
        • λΉŒλ” νŒ¨ν„΄
        • νŒ©ν† λ¦¬ λ©”μ„œλ“œ νŒ¨ν„΄
        • [생성 νŒ¨ν„΄] ν”„λ‘œν†  νƒ€μž… (Prototype Parttern)
        • 싱글톀
      • ꡬ쑰 νŒ¨ν„΄
        • μ–΄λŒ‘ν„° νŒ¨ν„΄
        • λΈŒλ¦Ώμ§€ νŒ¨ν„΄
        • 컴포짓(Composite) νŒ¨ν„΄
        • λ°μ½”λ ˆμ΄ν„°
        • ν”„λ‘μ‹œ
    • refactoring
      • 쀑볡 μ½”λ“œ
      • μ „μ—­ 데이터
      • κΈ΄ ν•¨μˆ˜
      • κΈ΄ λ§€κ°œλ³€μˆ˜ λͺ©λ‘
      • κ°€λ³€ 데이터
      • μ΄ν•΄ν•˜κΈ° νž˜λ“  이름
  • 자료ꡬ쑰
    • AVL Tree
    • Splay Tree
    • aaTree
    • array-list
    • 자료ꡬ쑰 μ‹œκ°„/곡간 λ³΅μž‘λ„
    • κ·Έλž˜ν”„
    • νž™
    • Red Black Tree
    • stack-queue
    • 트리 ( Tree )
  • DevOps
    • MSA
    • Kubernetes
      • AccessingAPI
      • controller
      • dashboard
      • kubernetes
      • object
      • pod
      • service
      • volume
  • Java
    • μ–΄λ…Έν…Œμ΄μ…˜
    • μ œμ–΄λ¬Έ
    • 데이터 νƒ€μž…
    • Enum
    • jvm
    • μ—°μ‚°μž
    • thread
    • Java8
      • CompletableFuture
      • Date/Time
      • μ–΄λ…Έν…Œμ΄μ…˜κ³Ό λ©”νƒ€μŠ€νŽ˜μ΄μŠ€
      • μΈν„°νŽ˜μ΄μŠ€
      • λžŒλ‹€μ‹
      • Optional
      • 슀트림
  • JavaScript
    • moduleProject
    • webpack-babel
    • μ½”μ–΄ μžλ°”μŠ€ν¬λ¦½νŠΈ
      • array
      • ν•¨μˆ˜ 바인딩
      • λ°μ½”λ ˆμ΄ν„°μ™€ ν¬μ›Œλ”©
      • Class
      • 비ꡐ μ—°μ‚°μž
      • Date λ‚΄μž₯ 객체
      • destructuring-assignment
      • function
      • ν•¨μˆ˜μ˜ prototype ν”„λ‘œνΌν‹°
      • κ°€λΉ„μ§€ μ»¬λ ‰μ…˜ ( Garbage Collection )
      • JSON (JavaScript Object Notation)
      • map-set
      • λ‚΄μž₯ ν”„λ‘œν† νƒ€μž…
      • newμ—°μ‚°μžμ™€ μƒμ„±μž ν•¨μˆ˜
      • 객체
      • Object.keys, values, entries
      • μ˜΅μ…”λ„ 체이닝 '?.'
      • ν”„λ‘œνΌν‹° ν”Œλž˜κ·Έ
      • ν”„λ‘œνΌν‹° μ’…λ₯˜
      • ν”„λ‘œν†  νƒ€μž…
      • 호좜 μŠ€μΌ€μ€„λ§ ( scheduling a call )
      • scope
      • this
      • type-conversions
      • type
      • ν•¨μˆ˜μ˜ μžλ£Œν˜•
      • var_let_const
  • Linux
    • κΈ°λ³Έ λͺ…λ Ήμ–΄
    • 파일 μ’…λ₯˜
    • λ¦¬λˆ…μŠ€
  • λ„€νŠΈμ›Œν¬
    • μ‘μš© 계측 ( Application Layer )
    • 였λ₯˜ κ²€μΆœκ³Ό 였λ₯˜ μ •μ •
    • Http
    • Http Header
    • 컴퓨터 λ„€νŠΈμ›Œν¬λž€
    • λ„€νŠΈμ›Œν¬ 계측
    • λ„€νŠΈμ›Œν¬ μ œμ–΄ μ˜μ—­
    • 전솑 계측 ( Transport Layer )
  • PHP
    • Facade
    • composer
    • scopeResolutionOperator
    • Laravel
      • SocialProvider
      • architecture
      • blade
      • controller
      • db
      • dbArchitecture
      • debug
      • eloquent
      • email
      • event
      • exceptionHandling
      • middleware
      • model
      • modelFactory
      • pagingLoading
      • queryBuilder
      • route
      • scout
      • seeding
      • tntsearch
      • validate
      • view
  • React
    • Next.js
    • React λž€?
  • Spring
    • Controller
    • μš”μ²­μ΄ λ“€μ–΄μ™”μ„λ•Œ μŠ€ν”„λ§μ΄ μ²˜λ¦¬ν•˜λŠ” 방법 ( 내뢀ꡬ쑰 )
    • ConfigurationProperties
    • Entity / DTO / VO
    • Maven
    • Repository와 DAO
    • μŠ€ν”„λ§ 빈
    • Spring Framework
    • MVC νŒ¨ν„΄
    • 도메인 μž…λ ₯κ°’ 검증
    • Spring Cloud
      • Spring Cloud
      • Eureka
    • Spring Data
      • JPA
      • JPA μ–΄λ…Έν…Œμ΄μ…˜
      • μ—”ν‹°ν‹° 비ꡐ
      • 볡합 킀와 식별 관계 λ§€ν•‘
      • JPA μ˜ˆμ™Έμ²˜λ¦¬
      • 객체지ν–₯ 쿼리
      • EntityManagerFactory와 EntityManager
      • JPA μ΅œμ ν™”
      • ν”„λ‘μ‹œμ™€ 연관관계 λ§΅ν•‘
      • 연관관계
      • 상속관계 λ§΅ν•‘
      • νŠΈλžœμž­μ…˜ λ²”μœ„μ™€ μ˜μ†μ„± μ»¨ν…μŠ€νŠΈ
      • 데이터 νƒ€μž…
      • MySQL μ—°κ²°
      • Pageable
    • Spring Projectλ“€κ³Ό library
      • Custom Serialize
      • Elasticsearch Index API
      • Spring HATEOAS
      • lombok (둬볡)
      • Model Mapper
      • Object Mapper
      • Representation Model
      • Spring REST Docs
      • Spring Boot
    • Spring Security
      • Spring Security
      • Authentication
      • Authentication Filter
      • Authorization Filter
      • Filter Chain
      • SecurityContext
      • Spring OAuth2.0
    • Spring Test
      • AssertJ
      • Junit5
      • JunitParams
      • Mock Object
  • DataBase
    • ALIAS
    • CONCAT
    • CTE
    • Group By
    • HAVING
    • IFNULL
    • 인덱슀
    • JOIN
    • ORDER BY
    • ROLLUP
    • SELECT
    • SELECT DISTINCT
    • SQL
    • WHERE
  • Web 상식
    • OAuth
    • WAS
    • HTTP톡신 기반 인증
    • λΈŒλΌμš°μ €
    • CSR κ³Ό SSR
    • HTTPS
    • Web
Powered by GitBook
On this page
  • κΈ°λ³Έ 문법
  • GROUP쑰건이 μ—¬λŸ¬κ°œ μΌλ•Œ
  • GROUPING()
  • 문법 μ˜ˆμ‹œ
  1. DataBase

ROLLUP

μ†Œκ³„μ™€ 총 합계λ₯Ό μƒμ„±ν•˜μ—¬ 좜λ ₯ν•˜κΈ° μœ„ν•œ ꡬ문

κΈ°λ³Έ 문법

SELECT
    select_list
FROM
    table_name
GROUP BY
    c1, c2, c3 WITH ROLLUP;
SELECT
    orderYear,
    productLine,
    SUM(orderValue) totalOrderValue
FROM
    sales
GROUP BY
    orderYear,
    productline
WITH ROLLUP;

GROUP쑰건이 μ—¬λŸ¬κ°œ μΌλ•Œ

κ³„μΈ΅μ μœΌλ‘œ κ·Έλ£Ήν™” μ„ΈνŠΈκ°€ λ§Œλ“€μ–΄μ§€λ©°, λ‘κ°œμ˜ COLUMN이라면 C1에 λŒ€ν•΄ C2λ“€μ˜ 합이 좜λ ₯λ˜κ³ λ‚˜μ„œ C1의 μ΄ν•©λ“€μ˜ 합이 좜λ ₯λœλ‹€.

좜λ ₯될 λ•Œ, ν•©μ˜ 기쀀이 된 COLUMN값은 NULL이 λœλ‹€.

orderYear
productLine
totalOrderValue

2003

Classic Cars

5571.80

2003

Montorcycles

2240.50

2003

Planes

4825.44

2003

Ships

5072.71

2003

Trains

2770.95

2003

Trucks and Buses

3284.28

2003

Vintage Cars

4080.00

2003

NULL

28045.68

2004

Classic Cars

8124.98

2004

Montorcycles

2598.77

2004

Planes

2857.35

2004

Ships

4301.15

2004

Trains

4646.88

2004

Trucks and Buses

4615.64

2004

Vintage Cars

2819.28

2004

NULL

29964.05

NULL

NULL

58009.75

GROUPING()

NULL κ²°κ³Ό 집합이 λΆ€λΆ„ν•©μ΄λ‚˜ 총합을 λ‚˜νƒ€λ‚΄λŠ”μ§€ ν™•μΈν•˜κΈ° μœ„ν•œ ν•¨μˆ˜

문법 μ˜ˆμ‹œ

SELECT
    orderYear,
    productLine,
    SUM(orderValue) totalOrderValue,
    GROUPING(orderYear),
    GROUPING(productLine)
FROM
    sales
GROUP BY
    orderYear,
    productline
WITH ROLLUP;
orderYear
productLine
totalOrderValue
GROUPING(orderYear)
GROUPING(orderYear)

2003

Classic Cars

5571.80

0

0

2003

Montorcycles

2240.50

0

0

2003

Planes

4825.44

0

0

2003

Ships

5072.71

0

0

2003

Trains

2770.95

0

0

2003

Trucks and Buses

3284.28

0

0

2003

Vintage Cars

4080.00

0

0

2003

NULL

28045.68

0

1

2004

Classic Cars

8124.98

0

0

2004

Montorcycles

2598.77

0

0

2004

Planes

2857.35

0

0

2004

Ships

4301.15

0

0

2004

Trains

4646.88

0

0

2004

Trucks and Buses

4615.64

0

0

2004

Vintage Cars

2819.28

0

0

2004

NULL

29964.05

0

1

NULL

NULL

58009.75

1

1

이런 νŠΉμ„±μ„ μ΄μš©ν•΄ IF와 ν•©μ³μ„œ ν‘œν˜„μ΄ κ°€λŠ₯ν•˜λ‹€

SELECT
    IF(GROUPING(orderYear),
        'All Years',
        orderYear) orderYear,
    IF(GROUPING(productLine),
        'All Product Lines',
        productLine) productLine,
    SUM(orderValue) totalOrderValue
FROM
    sales
GROUP BY
    orderYear ,
    productline
WITH ROLLUP;
orderYear
productLine
totalOrderValue

2003

Classic Cars

5571.80

2003

Montorcycles

2240.50

2003

Planes

4825.44

2003

Ships

5072.71

2003

Trains

2770.95

2003

Trucks and Buses

3284.28

2003

Vintage Cars

4080.00

2003

All Product Lines

28045.68

2004

Classic Cars

8124.98

2004

Montorcycles

2598.77

2004

Planes

2857.35

2004

Ships

4301.15

2004

Trains

4646.88

2004

Trucks and Buses

4615.64

2004

Vintage Cars

2819.28

2004

All Product Lines

29964.05

All Years

All Product Lines

58009.75

PreviousORDER BYNextSELECT

Last updated 3 years ago