2017-05-23 2 views
1

Ich bin neu bei Presto und suche nach der gleichen Funktionalität wie die Funktion group_concat in MySQL. Sind die folgenden zwei gleichwertig? Wenn nicht, irgendwelche Vorschläge, wie ich die Group_concat Funktionalität in Presto neu erstellen kann?Presto-Äquivalent von MySQL group_concat

MySQL:

select 
    a, 
    group_concat(b separator ',') 
from table 
group by a 

Presto: (. Finde diese als vorgeschlagen Presto Abhilfe here wenn Group_concat Funktionalität der Suche)

select 
    a, 
    array_join(array_agg(b), ',') 
from table 
group by a 

Antwort

1

Es gibt keine Funktion als diese Antwort, though the feature has been requested .

Das nächste Äquivalent wird in Ihrer Frage erwähnt.

WITH tmp AS (
SELECT 'hey' AS str1 
UNION ALL 
SELECT ' there' 
) 
SELECT array_join(array_agg(str1), ',', '') AS joined 
FROM tmp 
0

Versuchen Sie, diese anstelle von Group_concat in Presto mit ::

select 
    a, 
    array_join(array_agg(b), ',') 
from table 
group by a