Hi,

I would like to rewrite this as the following.

Also *1 does not achieve much and can be dropped.

You can try this as well as CTE, depending on what is the remaining portion of your query.

I would like to rewrite this as the following.

Also *1 does not achieve much and can be dropped.

You can try this as well as CTE, depending on what is the remaining portion of your query.

```
CASE
WHEN BAmt > 0 AND AAmt > 0 AND BAmt <= AAmt THEN SBAmt
WHEN BAmt > 0 AND AAmt > 0 AND BAmt > AAmt THEN SAAmt
ELSE 0
END
Where
FLOOR(SUM(BetAmtPTY) /250 * 1) BAmt
FLOOR(SUM(AmountPTY) / 250) * 1 AAmt
(SUM(BetAmtPTY)/250) * 1 SBAmt
(SUM(AmountPTY)/250) * 1 SAAmt
```