I has a problem:
In my SQLite (sqlite3 on android) database I have a table like so:
idImp  | cer  | caus
---------------------
id1    | 010  | D1
id1    | 010  | D2
id1    | 011  | D2
id1    | 011  | D3
id2    | 010  | D1
id2    | 010  | D2
id2    | 011  | D2
id2    | 011  | D4
and I'd like to get to
idImp | Conc
id1   | '010-D1-D2;011-D2-D3;'
id2   | '010-D1-D2;011-D2-D4;'
Using SQLite is it possible?? Does anyone have an idea how to make this work?
Thanks!
EDIT (SRY, There was an error in the result table) :
What I need is a SQL query that concatenates the fields "caus" and the field "cer" with specific separator grouped by "idImp".
I found in the documentation of sqlite group_concat (X, Y) that work on single column as it serves me, but I need to concatenate multiple columns and i don't know how to do...
Group the values in two steps:
SELECT idImp,
       group_concat(causConc, '') AS Conc
FROM (SELECT idImp,
             cer || '-' || group_concat(caus, '-') || ';' AS causConc
      FROM MyTable
      GROUP BY idImp,
               cer)
GROUP BY idImp
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With