첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

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

댓글을 달아 주세요