Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16013

GROUPING SETS Problem

$
0
0
Hi Guys,

Please refer to my query below:

Code:

      SELECT A.WorkPeriod,
                  A.EmployeeName,
                  A.EmployeeCode,
                  A.DepartmentDesc
                (SELECT B.ProjCode
                    FROM tblCharge AS B
                    INNER JOIN tblProj AS C
                        ON B.ProjectCode = C.Code
                  WHERE A.EmployeeCode = B.EmployeeCode ) AS ProjCode,
                SUM(Pay) AS Pay,
                SUM(Deminimis) AS Deminimis,
                SUM(Other) AS Other,
                SUM(Gift) AS Gift,
                SUM(Allowance) AS Allowance,
                SUM(Loan) AS Loan,
                SUM(SEC) As SEC,
                SUM(FCAL) AS FCAL
        FROM vyu_GetEmpDetails
      WHERE WorkPeriod= '2020-08-B'
          AND A.DepartmentDesc != 'DED'
      GROUP BY GROUPING SETS ((A.WorkPeriod, A.EmployeeCode, A.EmployeeName, A.DepartmentDesc), (A.DepartmentDesc))

The output is like this:

Name:  Output.jpg
Views: 18
Size:  24.5 KB

But I'm expecting something like this:

Name:  Result.jpg
Views: 17
Size:  25.1 KB

Can anyone help me how to achieve the latter result using grouping sets, cause i can't use ROLLUP and CUBE due to its not supported.

Thank you
Attached Images
  

Viewing all articles
Browse latest Browse all 16013

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>