Changing json_extract_path_text return type to integer

The result of the filter shows that the “ premium” column has integers. But when to get Sum of or AVG of, Metabase does not show this column eligible for mathematics operations.
“ premium” it self is extracted by using
select id, type,
json_extract_path_text(derived_data::json, 'derived_premium', 'value') as premium,
fields from quotations;
I would appreciate it if give me some insights on this?

Hi @aramit
The value of "premium" is a string instead of a number. Cast it as a number.

Thanks @flamber,
select id, type,
CAST((json_extract_path_text(derived_data::json, 'derived_premium', 'value') as premium) AS float)
fields from tba;

ERROR: syntax error at or near "AS" Position: 0

@aramit Yes, that's an invalid query - the error is coming from your database, not Metabase.
Try something like
json_extract_path_text(derived_data::json, 'derived_premium', 'value')::float
Otherwise you would have to look in your database documentation.

Works perfect! Thanks a lot@flamber!