Reputation: 73
input:
cursor.execute('SELECT SUM(CAST("Item Total" as FLOAT)) FROM price')
res_sum = cursor.fetchone()
print(res_sum)
output:
(0.0,)
example: $47.99 + $47.99 + $47.99 + $47.99
Upvotes: 0
Views: 57
Reputation: 56958
You could use SELECT SUM(CAST(substr("item total",2) AS FLOAT)) FROM price;
However, it would be better to store the values without the currency character. You could always prepend the value when extracting if so desired.
e.g. SELECT '$'||SUM(CAST(substr("item total",2) AS FLOAT)) FROM price;
would output $191.96 as opposed to just 191.96.
Upvotes: 1