如何将PostgreSQL array_agg函数转换为SQLite? [英] How to translate the PostgreSQL array_agg function to SQLite?
本文介绍了如何将PostgreSQL array_agg函数转换为SQLite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此查询在PostgreSQL中有效:
This query works in 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?
but it does not work in SQLite, because SQLite does not have the array_agg()
function. How can this query be converted to SQLite?
推荐答案
对于此查询,您可以使用 group_concat ,它直接返回一个字符串:
For this query, you can use group_concat, which directly returns a string:
SELECT ..., group_concat(tk1.TName || ',' || ot.TTime, ' - ')
FROM ...
这篇关于如何将PostgreSQL array_agg函数转换为SQLite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文