첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

SELECT
    SalesGroup                                            AS [판매 그룹]
   ,SUM(SalesAmount)                                      AS [소계]
   ,SUM(SalesAmount) * 100 / SUM(SUM(SalesAmount)) OVER() AS [비율]
   ,SUM(SUM(SalesAmount)) OVER()                          AS [총계]
FROM
(
    SELECT 10 AS SalesAmount, '영업1팀' AS SalesGroup UNION ALL
    SELECT 10 AS SalesAmount, '영업1팀' AS SalesGroup UNION ALL
    SELECT 60 AS SalesAmount, '영업2팀' AS SalesGroup UNION ALL
    SELECT 40 AS SalesAmount, '영업2팀' AS SalesGroup UNION ALL
    SELECT 40 AS SalesAmount, '영업3팀' AS SalesGroup UNION ALL
    SELECT 25 AS SalesAmount, '영업3팀' AS SalesGroup UNION ALL
    SELECT 15 AS SalesAmount, '영업3팀' AS SalesGroup
) A
GROUP BY SalesGroup;
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요