I am using the hxtt sql driver for csv files. It only supports plain sql. is there a way to simulate group concat using plain sql statements?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How plain? If you can use triggers then you can do it fairly simply. I’ve used this trick before in SQLite3 when I’ve needed a group_concat() that allows me to specify the order in which values are to be concatenated (SQLite3 does not provide a way to do that).
So let’s say we have a table like this:
and you want to concatenate the values of v ordered by num, with some separator character, let’s say a comma.
Now we can:
Finally, this is a sqlite3 session showing that this works:
Now, this isn’t pure SQL, because it depends on triggers. Between recursive triggers and all the ways to do conditionals in SQL you have a Turing complete system. But if you don’t have triggers, or any procedural extensions, no generator tables… then not so much.
I know nothing about hxtt, so maybe this won’t help you. But SQLite3 can deal with CSV, so maybe SQLite3 can help you…