2016-09-19 2 views
0

다음은 내 쿼리와 결과 열이지만 쿼리를 추가하여 전체 열을 얻는 방법을 알지 못합니다.쿼리에 대/소문자 함수가 포함 된 SQL Server의 총 행을 추가하는 방법

Select 
    case PlacementVerificationmethod 
     when 107 then 'contact center' 
     when 1 then 'work number/3rd party verification' 
     when 101 then 'Placement call' 
     when 102 then 'walk in/Self report' 
     when 103 then 'Email' 
     when 104 then 'Employer Report' 
     when 105 then 'In person with participant' 
     when 106 then 'In person with employer' 
     else 'unknown' 
    end as 'Placement method', 
    count(*) as 'Total Placement' 
from 
    AssessEmploymentPlacement 
group by 
    PlacementVerificationMethod 

결과 : 당신이 총 을 원하는 경우에

In person with employer    145 
Placement call      13813 
work number/3rd party verification 3492 
Employer Report      4463 
In person with participant   168 
unknown       61387 
walk in/Self report     2227 
Email        115 

답변

0

은, 당신은 할 수 있습니다 : 당신은 총을 가진 다른 을 원하는 경우에

Select (case PlacementVerificationmethod 
      when 107 then 'contact center' 
      when 1 then 'work number/3rd party verification' 
      when 101 then 'Placement call' 
      when 102 then 'walk in/Self report' 
      when 103 then 'Email' 
      when 104 then 'Employer Report' 
      when 105 then 'In person with participant' 
      when 106 then 'In person with employer' 
      else 'unknown' 
     end) as [Placement method], 
     count(*) as [Total Placement], 
     sum(count(*)) over() as Total 
from AssessEmploymentPlacement 
group by PlacementVerificationMethod; 

후 사용 그룹화 집합 또는 롤업 :

group by grouping sets ((PlacementVerificationMethod),())