mburk1968
asked on
SQL 2005 Table Function Help
What I am trying to do is when the [Account Nbr] = '01-2125-000000-010000-00'
the LOBtotal should be the sum 'CM','OC','GL','Tails','Mi ni-Tails' in the Case Statement. So I would have an LOBTotal for '01-2125-000000-010000-00' And one for '01-2125-00PTL0-010000-00' I tried using a Group by but it didn't work.
the LOBtotal should be the sum 'CM','OC','GL','Tails','Mi
-- detail for Ceded Balances Payable
SELECT BatchID = 'IS4WPACP' + @ToDate
,DocNbr = 'CEDEDPREMIUM' + @ToDate
,[Account Nbr] = CASE
WHEN LOB_LOB IN ('CM','OC','GL','Tails','Mini-Tails') THEN '01-2125-000000-010000-00'
WHEN LOB_LOB = 'Claims Made Plus Prepaid Tail' THEN '01-2125-00PTL0-010000-00'
END
, LOBtotal
,[Description] = 'CEDEDPREMIUM'
FROM dbo.LOB
WHERE lobtob = 'Ceded Written' AND LOB_LOB IN ('CM','OC','GL','Tails','Mini-Tails','Claims Made Plus Prepaid Tail')
ASKER
Currently I am getting this as my Result Set.
BatchID DocNbr Account Nbr LOBtotal Description
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 000000-010 000-00,166 287.96,CED EDPREMIUM
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 000000-010 000-00,320 6.88,CEDED PREMIUM
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 000000-010 000-00,359 7.65,CEDED PREMIUM
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 00PTL0-010 000-00,206 3.04,CEDED PREMIUM
This is what I want...
Account Number is the Sum of the three
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 000000-010 000-00,-17 3092.49,CE DEDPREMIUM
IS4WPACP10312010,CEDEDPREM IUM1031201 0,01-2125- 00PTL0-010 000-00,206 3.04,CEDED PREMIUM
BatchID DocNbr Account Nbr LOBtotal Description
IS4WPACP10312010,CEDEDPREM
IS4WPACP10312010,CEDEDPREM
IS4WPACP10312010,CEDEDPREM
IS4WPACP10312010,CEDEDPREM
This is what I want...
Account Number is the Sum of the three
IS4WPACP10312010,CEDEDPREM
IS4WPACP10312010,CEDEDPREM
ASKER
Did that help? Basically I need the Lobtotal for the first account number and the second. Instead I am getting the individual totals.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Posted code that solved my question. I used an outer query.
Can you explain what you are lookng for with an example?