honeysql 2026-04-01

Is it possible to use ORDER BY within a GROUP_CONCAT, like this "SELECT GROUP_CONCAT(ct.Name ORDER BY ct.ObjectId)..."

Or even worse -

(str "GROUP_CONCAT("
                        "CONCAT(cm.Name, "
                        "CASE WHEN ta.EndDate > " unix
                        " AND ta.LatestModule > 0"
                        " THEN CONCAT(' (', DATEDIFF(NOW(), FROM_UNIXTIME(ta.LatestModuleDate)) - 1, ' days)')"
                        " ELSE '' END)"
                        " ORDER BY ta.ObjectId)")

Oh god, why did you use str like that? :D You can have multiline strings just fine. As for the question:

(sql/format {:select [[[:group_concat [:order-by :ct/Name :ct/ObjectId]]]]})
=> ["SELECT GROUP_CONCAT(ct.Name ORDER BY ct.ObjectId ASC)"]

🙏 1