postgresql - 如何将 PostgreSQL array_agg 函数转换为 SQLite?

标签 postgresql sqlite android-sqlite aggregate-functions

此查询适用于 PostgreSQL:

  Select    ot.MCode,array_to_string(array_agg(tk1.TName || ',' || ot.TTime), ' - ') as oujyu_name_list
    From    TR_A ot
    inner join MS_B tk1 on ot.Code = tk1.Code
    Where   ot.Code in (Select Code From TR_C ) 
    Group byot.MCode

但它在SQLite 中不起作用,因为SQLite 没有array_agg() 函数。如何将此查询转换为 SQLite?

最佳答案

对于此查询,您可以使用 group_concat , 直接返回一个字符串:

SELECT ..., group_concat(tk1.TName || ',' || ot.TTime, ' - ')
FROM ...

关于postgresql - 如何将 PostgreSQL array_agg 函数转换为 SQLite?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26922230/

相关文章:

postgresql - 插入记录时自动在 Postgres 中设置到期日期

java - Hibernate物化 View ,嵌入两个Entity?

ruby-on-rails - 使用 postgres 在 rails 中使用 DISTINCT ids 进行排序

json - Martini 中的 JSON 编码错误

android - 如何显示搜索 View 最近的搜索历史

android - Sqlite 数据库中的 ID 冲突?

sql - 然后使用前 10 个查询来搜索与其关联的所有记录

python - 为什么 .count() 在带有 | 的 peewee 查询中返回错误的数字(联盟)?

python - 在 Python 中将 JSON 转换为 SQLite - 如何将 json 键正确映射到数据库列?

java - 空对象引用上的 int android.database.Cursor.getCount()'