How to concatenate strings of a string field in a PostgreSQL 'group by' query?

前端 未结 14 1429
北荒
北荒 2020-11-22 02:37

I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table:

ID   COMPANY_ID   EMPLOYEE
1    1               


        
14条回答
  •  误落风尘
    2020-11-22 03:12

    I'm using Jetbrains Rider and it was a hassle copying the results from above examples to re-execute because it seemed to wrap it all in JSON. This joins them into a single statement that was easier to run

    select string_agg('drop table if exists "' || tablename || '" cascade', ';') 
    from pg_tables where schemaname != $$pg_catalog$$ and tableName like $$rm_%$$
    

提交回复
热议问题