Skip to main content
deleted 40 characters in body
Source Link
JSmith
  • 143
  • 6

I've managed to make it work by doing:

select project_uid, sum(col_size) FROM (
  (select COALESCE(sum(pg_column_size(s)), 0) as col_size, project_uid
  from editor_s s
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(o)), 0) as col_size, project_uid
  from editor_o o
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(e)), 0) as col_size, project_uid
  from editor_c e
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(ss)), 0) as col_size, project_uid
  from editor_ss ss
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
) 
 as total group by project_uid;

Thank you to @Lennart

I've managed to make it work by doing:

select project_uid, sum(col_size) FROM (
  (select COALESCE(sum(pg_column_size(s)), 0) as col_size, project_uid
  from editor_s s
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(o)), 0) as col_size, project_uid
  from editor_o o
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(e)), 0) as col_size, project_uid
  from editor_c e
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(ss)), 0) as col_size, project_uid
  from editor_ss ss
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
) 
 as total group by project_uid;

Thank you to @Lennart

I've managed to make it work by doing:

select project_uid, sum(col_size) FROM (
  (select COALESCE(sum(pg_column_size(s)), 0) as col_size, project_uid
  from editor_s s
  where user_uid = 'some_user_uid'
  group by project_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(o)), 0) as col_size, project_uid
  from editor_o o
  where user_uid = 'some_user_uid'
  group by project_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(e)), 0) as col_size, project_uid
  from editor_c e
  where user_uid = 'some_user_uid'
  group by project_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(ss)), 0) as col_size, project_uid
  from editor_ss ss
  where user_uid = 'some_user_uid'
  group by project_uid )
) 
 as total group by project_uid;

Thank you to @Lennart

Source Link
JSmith
  • 143
  • 6

I've managed to make it work by doing:

select project_uid, sum(col_size) FROM (
  (select COALESCE(sum(pg_column_size(s)), 0) as col_size, project_uid
  from editor_s s
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(o)), 0) as col_size, project_uid
  from editor_o o
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(e)), 0) as col_size, project_uid
  from editor_c e
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
  UNION ALL
  ( select COALESCE(sum(pg_column_size(ss)), 0) as col_size, project_uid
  from editor_ss ss
  where user_uid = 'some_user_uid'
  group by project_uid, user_uid )
) 
 as total group by project_uid;

Thank you to @Lennart