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

Different rules for different values in SQL Pivot?

$
0
0

This works without a problem:

PIVOT
(
SUM(PremAmount)
FOR trans IN ([1],[8],[9])
) AS pvt

Is there a way to have a different rule for different trans codes?
For Example:

PIVOT
(
SUM(PremAmount)
FOR trans IN ([1],[8],[9])
SUM(LossAmount)

FOR trans IN ([2],[3],[6],[7])
) AS pvt

Thank you in advance for any advice!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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