vertica - SQL add comma sepeared values of a column -
i have table
column 1 | column 2 -------------------- 1,2,3, | abc 2,3,4, | xyz 1, | cc 1,2, | aa
i want query sums these comma separated values in vertica
column 1|column 2 --------|--------- 6 | abc 9 | xyz 1 | cc 3 | aa
solution sql server
select col2, sum(cast(value int)) tab cross apply string_split(col1, ',') group col2;
Comments
Post a Comment