Skip to content
Advertisement

replace value with 1 and apply SUM method in one query SQL

I need to replace the value in column imp from 1-0 to 1 and sum it up. Column imp is a STRING, so it also needs to be converted to INT. Each line represents the record so I need to sum up imp and group by another column (in order to get the number of records for a specific Advertiser) My data looks like this:

My query:

Error message: No matching signature for aggregate function SUM for argument types: STRING Desired output:

Advertisement

Answer

Are you just looking for aggregation and count()?

Or, if you specifically want to count values of '1-0', use COUNTIF():

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement