Hi Folks,
I have 2 queries that I'd like to combine but I'm having a rare old time figuring out the correct syntax.
Firstly the table layout - tblLossEvent.
The key fields are RiskCat which will only ever have 5 different enteries, ActLoss which is either 1 or 0 and LossValCurr which is the loss value associated with RiskCat.
Here are the 2 queries.
and
The format of the result should be RiskCat, ActLoss, PotLoss where 1 is an actual loss and 0 is potential.
I've had varying degrees of success, but not managed to correctly get the format that I need.
EG
RiskCat ActLoss PotLoss
ABCD 1234 5678
BCDE 2345 6789
...and so on.
Any ideas would be appreciated.
Thanks,
Jon
I have 2 queries that I'd like to combine but I'm having a rare old time figuring out the correct syntax.
Firstly the table layout - tblLossEvent.
The key fields are RiskCat which will only ever have 5 different enteries, ActLoss which is either 1 or 0 and LossValCurr which is the loss value associated with RiskCat.
Here are the 2 queries.
Code:
SELECT RiskCat, SUM(LossValCur) AS ActLoss
FROM dbo.tblLossEvent
WHERE (LossType = 1)
GROUP BY RiskCat
Code:
SELECT RiskCat, SUM(LossValCur) AS PotLoss
FROM dbo.tblLossEvent
WHERE (LossType = 0)
GROUP BY RiskCat
The format of the result should be RiskCat, ActLoss, PotLoss where 1 is an actual loss and 0 is potential.
I've had varying degrees of success, but not managed to correctly get the format that I need.
EG
RiskCat ActLoss PotLoss
ABCD 1234 5678
BCDE 2345 6789
...and so on.
Any ideas would be appreciated.
Thanks,
Jon