Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

PIVOT with multiple columns to add and multiple levels of grouping

$
0
0

Hi friends,

I got a table with the columns in the form of:

CRITERIA_A,

CRITERIA_B,

CRITERIA_C,

AMOUNT_A,

AMOUNT_B,

AMOUNT_C,

AMOUNT_D

Any way to design a pivot to present the table reflecting:

Sums of Amount_A, Amount_B, Amount_C, Amount_D

For Rows reflecting grouping levels on:

Criteria_B, Criteria_C

and Columns breakup for:

Criteria_A?

An example like:

 Criteria_A1   Criteria_A2   Criteria_A3   Criteria_A4
Row LabelsSum of Amount_ASum of Amount_BSum of Amount_CSum of Amount_DSum of Amount_ASum of Amount_BSum of Amount_CSum of Amount_DSum of Amount_ASum of Amount_BSum of Amount_CSum of Amount_DSum of Amount_A
Criteria_B3941073612784132411762416672938
Criteria_C12425549146654924166729 
Criteria_C270823178        38
Criteria_C3    38413178     
Criteria_C4    3225549     
Criteria_B15614278263225678    24
Criteria_C224662683225678     
Criteria_C332765218         
Criteria_C4            24
Criteria_B216230926481132230155124142552838
Criteria_C1387626862989866142552838
Criteria_C28615718644701325758     
Criteria_C338765229         
Criteria_B4    10014813011656142935746
Criteria_C1        2466674932
Criteria_C2        327626814
Criteria_C3    76827867     
Criteria_C4    24665249     
Grand Total3125583782343485353934249418321294146


Thanx in advance, Best Regards, Faraz A Qureshi




Viewing all articles
Browse latest Browse all 12890

Trending Articles



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