Convert bool to int in postgresql

postgresql, sql

Solution

Try `boolean_col::int`:

SELECT
item.item_number, SUM(item.item_active::int)
FROM 
public.item
GROUP BY item.item_number;

Problem

I am trying to run the following sql statement. ``` SELECT item.item_number, SUM(item.item_active) FROM public.item GROUP BY item.item_number; ``` I am returning the following error: ``` ERROR: function sum(boolean) does not exist ``` I figure if I can use a function to change the `item.item_active` to an integer, then it can take the sum of the active records.

Original source

Related problems