I have a table like this:
id | array
1 | {8,8,8,x,u,x,x}
2 | {8,8,8,x,8,x,x}
...|...
n | {8,u,u,x,u,x,x}
It contains time of work each employee (cols in array are days of week, u and x are days free of work).
Is it possible to aggregate those rows into one containing sum of each col (if it's an int)?
My goal is to get from query answer like this: {24,16,16,0,8,0,0}
xandu? Your Postgres version and the data type in use? Do you want to aggregate n rows or just combine two?string_to_arrayso i assume that all data in it are strings; pgsql version is 9.0'09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE|09600480Z|XE|XE'... i need to aggregatenrows like this and in this aggregated cell i need to have an array. From each part of string i need only first four digits. For example: row1:'09600480Z|XE|XE|09600480Z|...'; row2:'09600480Z|09600480Z|XE|XE|...'=>{1920,960,0,960,...}because 09600480Z = 960; XE = 0 so 09600480Z + 09600480Z = 960 + 960 = 1920; XE + 09600480Z = 0 + 960 =960;