✌️
Studylog
See More
Studylog
Studylog
  • INTRO
  • AWS
    • AWS101
      • Virtualization and the AWS structures
      • AWS account and free-tier
      • AWS IAM
      • AWS EC2
        • EC2 basic
        • ENI and EIP
        • Elastic Block Storage
        • Auto Scaling
        • Elastic Load Balancer
  • IaC
    • Terraform
      • License Change
      • Tutorial
      • Module
      • Versioning
  • Airflow
    • Airflow-Ninja
      • Introduction and Goal
      • Tutorial: Settings
      • Tutorial: Module Import, Alert
  • Docker
    • Production with Docker
      • Customizing root directory
  • Network
    • Network-Handbook
      • Introduction and Goal
      • OSI7Layer
      • DNS
      • SSL/TLS
  • Comupter Architecture
    • Basic
      • Introduction and Goal
      • Chapter 1. The Internal Language of Computers
      • Chapter 2. Combinatorial Logic
      • Chapter 3. The Essentials of Memory and Disk Sequential Logic
    • Hands-on
      • Introduction and Goal
      • theory
        • Chapter 1. Logic Gates
        • Chapter 2. ALU
      • project
        • Project 1. Elementary logic gates implement
        • Project 2. Boolean Arithmetic
  • Java
    • Readable Code
      • 학습 목적
      • 추상화
      • 논리적 사고 흐름
      • 객체지향 이론
      • 객체지향 코드 적용하기
      • 코드 다듬기
      • 읽기 좋은 코드를 도와줄 조언들
  • Spring Boot
    • Practical Testing
      • 테스트 사전 지식
      • 스프링 레이어드 아키텍처 테스트하기
        • Persistence Layer
        • Business Layer
        • Presentation Layer
    • 스프링 핵심 원리 - 기본편
      • 객체 지향 설계와 스프링
      • 스프링 핵심 원리 이해
        • 예제 만들기
        • 객체 지향 원리 적용
        • 스프링 컨테이너와 스프링 빈
  • Python
    • Effective Python
      • Introduction and Goal
      • Closure: Lazy Evaluation And Eager Evaluation
      • Python public attributes are better getter-setter
      • No refactoring attribute, we can use property decorator
      • You can do it, but it means you don't have to
  • Playgrounds
    • Java Playground
      • 학습 목적
      • 숫자 야구 게임
        • 학습 테스트
        • 문자열 계산기
        • 숫자 야구 게임 구현
        • 숫자 야구 게임 다시 구현하기
      • 자동차 경주
        • 문자열 덧셈 계산기
        • 자동차 경주 미션 구현
      • 좌표 계산기
        • 연료 주입
        • 좌표 계산기 미션 구현
    • Infra Playground
      • VPC: 망분리 그리고 테스트
      • 컨테이너 사전 지식
      • 화면 성능 개선 전 학습 테스트
      • SSM: Session Manager
      • SQL, 이 정도는 알아야지 😎
      • Subway-Map
        • 망 구성하기
        • 서버 구성하기
        • 화면 성능 개선하기
      • Conference Platform
        • 망 구성하기
        • 서버 구성하기
        • 화면 성능 개선하기
  • Tools
    • SOPS
    • Bruno
    • 🖥️FCK-NAT
    • 🧊Pulumi
Powered by GitBook
On this page
  • 실습하기
  • 200개 이상 팔린 상품명과 그 수량을 수량 기준 내림차순으로 보여주세요.
  • 많이 주문한 순으로 고객 리스트(ID, 고객명)를 구해주세요. (고객별 구매한 물품 총 갯수)
  • 많은 돈을 지출한 순으로 고객 리스트를 구해주세요.
  1. Playgrounds
  2. Infra Playground

SQL, 이 정도는 알아야지 😎

조회 성능 개선하기 미션을 진행할 때 최소한으로 필요한 SQL 역량이 있는지를 확인하기 👍

PreviousSSM: Session ManagerNextSubway-Map

Last updated 2 months ago

만약 SQL 리부트를 하고 싶다면?

https://www.youtube.com/watch?v=_DgpFbcGuAc

실습하기

해당 사이트에서 아래 쿼리를 작성해보세요.

1

200개 이상 팔린 상품명과 그 수량을 수량 기준 내림차순으로 보여주세요.

SELECT 
	pd.ProductID AS "상품아이디",
	pd.ProductName AS "상품명",
	SUM(od.Quantity) AS "총수량"
FROM OrderDetails AS od
INNER JOIN Products AS pd
	ON od.ProductID = pd.ProductID
GROUP BY pd.ProductID
HAVING SUM(od.Quantity) >= 200
ORDER BY SUM(od.Quantity) DESC;
2

많이 주문한 순으로 고객 리스트(ID, 고객명)를 구해주세요. (고객별 구매한 물품 총 갯수)

SELECT
    cs.CustomerID AS "고객아이디",
    cs.CustomerName AS "고객이름",
    SUM(Quantity) AS "주문량"
FROM Orders AS od
INNER JOIN Customers AS cs
	ON cs.CustomerID = od.CustomerID
INNER JOIN OrderDetails AS od_detail
	ON od.OrderID = od_detail.OrderID
GROUP BY cs.CustomerID
ORDER BY SUM(Quantity) DESC;
3

많은 돈을 지출한 순으로 고객 리스트를 구해주세요.

SELECT
    cs.CustomerID AS "고객아이디",
    cs.CustomerName AS "고객이름",
    SUM(Quantity * Price) AS "지출금액($)"
FROM Orders AS od
INNER JOIN Customers AS cs
	ON cs.CustomerID = od.CustomerID
INNER JOIN OrderDetails AS od_detail
	ON od.OrderID = od_detail.OrderID
INNER JOIN Products AS pd
	ON od_detail.ProductID = pd.ProductID
GROUP BY cs.CustomerID
ORDER BY SUM(Quantity * Price) DESC;