I'm trying to calculate open ratio for our subscribers by adding up the number of emails they have been sent, number of those emails they have opened and then finally trying to calculate the ratio by taking their opens/sent. The problem I'm finding is that records with results not equal to "100" are loading with "0.00" instead of the true calculation. The source data extension and the target are the same, the query is set to Update.
Example Data Extension:
SubscriberKey | SentCount | OpenCount | Ratio
(Text Char-254) | (Number) | (Number) | (Decimal 18,4)
11111 | 25 | 5 |
22222 | 13 | 8 |
33333 | 25 | 5 |
44444 | 15 | 15 |
55555 | 12 | 0 |
Example of Current Result:
SubscriberKey | SentCount | OpenCount | Ratio
(Text Char-254) | (Number) | (Number) | (Decimal 18,4)
11111 | 25 | 5 | 0.00
22222 | 13 | 8 | 0.00
33333 | 25 | 5 | 0.00
44444 | 15 | 15 | 100.00
55555 | 12 | 0 | 0.00
Example Query:
SELECT
c.SubscriberKey,
CAST(((c.OpenCount / c.SentCount) * 100) AS DECIMAL(18, 2)) as Ratio
FROM DataTable c
Goal Result:
SubscriberKey | SentCount | OpenCount | Ratio
(Text Char-254) | (Number) | (Number) | (Decimal 18,4)
11111 | 25 | 5 | 20.00
22222 | 13 | 8 | 61.54
33333 | 25 | 5 | 20.00
44444 | 15 | 15 | 100.00
55555 | 12 | 0 | 0.00