此查询适用于 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/