Posted inSQL
Microsoft
18 years ago
Mutiple aggregates in PIVOT
Currently the PIVOT operator is:
Declined
ProgrammabilitySuggestionsDeclined
Company Response
Microsoft
Company Response
Up: 12<=-=Nov 13 2006 6:46PM=-=>Thank you for submitting this feature request. This is now under consideration for upcoming version of SQL Server.�G2<=-=Mar 10 2011 6:15PM=-=>Hello Mark,I have resolved your request as duplicate of one below:http://connect.microsoft.com/SQLServer/feedback/details/127071We will track your feature request as part of that one.�Umachandar, SQL Programmability Team<=-=Mar 10 2011 11:49PM=-=>I do not agree that this request is a duplicate of feedback 127071. That feedback is for a dynamic column list (dynamic IN) , where the internal query determines the shape of the output result set. This query is to support multiple aggregates; the shape of the output result set remains static. Specifically I am not suggesting any change in the IN () clause, which is the target of 127071.A concrete examples that we have face is when dealing with currencies � we need to simultanously aggregate the local currency and the foreign currency amounts. Currently we do this using the brute force approach (with a long list of sum (case �)<=-=Feb 9 2016 5:21AM=-=>Yes, please. This would be very useful.<=-=Aug 26 2016 6:38AM=-=>Yes add support for multiple aggregates, please.Also please add support for multiple columns in the FOR clause.Oracle has it since 11g:SELECT *FROM pivot_dataPIVOT (SUM AS sum, COUNT AS cntFOR deptno IN (10 AS d10_sal,20 AS d20_sal,30 AS d30_sal,40 AS d40_sal));andSELECT *FROM pivot_dataPIVOT (SUM AS sum, COUNT AS cntFOR (deptno,job) IN ((30, �SALESMAN�) AS d30_sls,(30, �MANAGER�) AS d30_mgr,(30, �CLERK�) AS d30_clk));I agree with Mark Yudkin, this request is in no way duplicate of Feedback 127071
Vote
0 Comments