0

What I want to do is pretty simple and I even think I've done it before; I just can't remember it.

ReinType    Coverage    ReCompany   AmountInForce   StatReserves    StatReserveExtra    ExcessCashValue DeficientPremiumReserve Stat2PUAReserve Stat2OYTReserve SubstandardOYT
RPRREIN BASE    ALLIANZ (K) 3305506.00  35979.82    2778.16 0   0   0.00    0.00    0
ULRPR   BASE    ALLIANZ (K) 1323210.00  24966.79    5697    0   0   0.00    0.00    0
ULRPR   BASE    BENEFICIAL LIFE (BL)    18339535.00 54467.53    790.13  0   0   0.00    0.00    0
MODCO   BASE    BUS MEN ASSUR (E)   1006577.00  566569.17   2289.57 4605.44 92.45   78415.61    400.64  0
MODCO   NEWDIM  BUS MEN ASSUR (E)   658.00  385.65  0   0   0   0.00    0.00    NULL
RPRREIN BASE    BUS MEN ASSUR (P)   65260.00    5283.45 0   0   0   0.00    0.00    NULL
COINSURE    BASE    CNA (9) 19152525.00 117831.7    57618.22    0   0   0.00    0.00    0
COINSURE    BIO CNA (9) 6808203.00  8004.2  0   0   0   0.00    0.00    NULL
COINSURE    FLATX   CNA (9) 1259425.00  1445.72 0   0   0   0.00    0.00    NULL
RPRREIN BASE    CNA (9) 198104996.00    733905.880000001    55875.78    0   0   0.00    0.00    0
RPRREIN TERM RDR    CNA (9) 8642375.00  10476.13    2699.85 0   0   0.00    0.00    0
ULFLATX UL FLATX    CNA (9) 212720.00   118.13  0   0   0   0.00    0.00    NULL
ULRPR   BASE    CNA (9) 223013469.00    1980612.21  51517.54    0   0   0.00    0.00    0
ULRPR   TERM RDR    CNA (9) 469200.00   1026.11 256 0   0   0.00    0.00    0
COINSURE    BASE    COLOGNE (C) 1848128.00  1248961.51  2537.26 2053.8  308.37  66626.65    1758.88 0
COINSURE    DEF ADDS    COLOGNE (C) 0.00    13750   0   0   0   0.00    0.00    NULL
COINSURE    DIS WP  COLOGNE (C) 2627.00 10412.14    0   0   0   0.00    0.00    NULL
COINSURE    MPRAR   COLOGNE (C) 502252.50   421721.33   0   0   0   0.00    0.00    NULL
COINSURE    NEWDIM  COLOGNE (C) 1416.00 937.79  0   0.01    0   0.00    0.00    NULL
COINSURE    WP  COLOGNE (C) 2488.58 91.93   0   0   0   0.00    0.00    NULL
COINSURE    FLATX   COLOGNE (X) 1595706.00  4552.49 0   0   0   0.00    0.00    NULL
RPRREIN BASE    COLOGNE (X) 202172511.00    514207.93   117499.93   0   0   0.00    0.00    0

I'm sorry about the quality of the table. I still don't know how to make one properly when asking questions on this site. Anyway What I want to do is have a column that will sum each row for those last 7 columns.

This is the query:

SELECT top 100 percent 
tblReinsurance.ReinType, 
tblReinsurance.Coverage, 
tblReinsurance.ReCompany,
Sum(tblReinsurance.AMOUNT_INFORCE) AS AmountInForce,
Sum(tblReinsurance.StatReserve) AS StatReserves,
SUM(tblReinsurance.StatResX) AS StatReserveExtra, 
Sum(tblReinsurance.ExcessCashValue) AS ExcessCashValue,
Sum(tblReinsurance.DefPremiumReserve) AS DeficientPremiumReserve,
Sum(tblReinsurance.STAT2_PUA_RES) AS Stat2PUAReserve, 
Sum(tblReinsurance.STAT2_OYT_RES) AS Stat2OYTReserve, 
Sum(tblReinsurance.OYTRS2X) AS SubstandardOYT


FROM tblReinsurance join tblCoverageFaceAmountMultiplier

ON tblReinsurance.Coverage = tblCoverageFaceAmountMultiplier.Coverage

WHERE (((tblReinsurance.TERM_REASON)='A') AND ((tblReinsurance.ISSUE_DATE)<=tblReinsurance.[VAL_DATE])) and COMPANY_CODE = 'NL' 
--AND tblCoverageFaceAmountMultiplier.FaceAmountMultiplier = 1

GROUP BY 
tblReinsurance.ReCompany,
tblReinsurance.ReinType, 
tblReinsurance.Coverage
order by 
tblReinsurance.ReCompany,
tblReinsurance.ReinType, 
tblReinsurance.Coverage
4

1 回答 1

1

你问的是 WITH ROLLUP 吗?我觉得你的问题有点难以理解。

MSDN 文档


编辑那么你为什么不只是在你的选择列表中添加另一列。

Sum(tblReinsurance.StatReserve) + SUM(tblReinsurance.StatResX) + Sum(tblReinsurance.DefPremiumReserve) AS SUMMED_SOME_COLUMNS
于 2013-06-04T19:26:07.073 回答