첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
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

댓글을 달아 주세요