Tuesday, 6 December 2016

SQL Group With Group Total

  1. SELECT isnull(WO_status,0) as WO_status,          
  2. (case  when MwO.WO_status=1 then 'Open' when MwO.WO_status=2 then 'Close' when MWO.WO_status=3 Then  'Short Close'          
  3. when MwO.WO_status=4 then 'Cancel'          
  4.  else 'Total' endas statusR,          
  5. count(*) as countValue                            
  6. FROM   M_WorkOrder MwO                         
  7.  inner join    M_WorkorderDetails MwOd  on MwO.WOID=MwOd.WOD_WOID                                                        
  8. INNER join BILL_KEYWORD BK  on BK.id=MwOd.WOD_KEYID                                                        
  9. INNER join billing_from bf      on bf.id=MwO.WO_CID                               
  10.  where  (MwOd.WOD_CUserID=15 or 15 =0 )              
  11.  group by WO_status  WITH ROLLUP

No comments:

Post a Comment

Getting Available Server Disk Space (Total Size / Free Space) SQL Query

SELECT distinct(volume_mount_point), total_bytes/1048576 as Size_in_MB, total_bytes/1048576/1024 as Size_in_GB, available_bytes/1048576 ...