我想在GROUP_CONCAT
中添加订单请求
SELECT LRU.InstanceDesc as lru ,
GROUP_CONCAT((DataSourceGroup.DataSourceGroupID||'~'||TYPE||'~'||DataSource.`NDOID`||'~'||DataSource.Name ),'@') as data_souce ,
FROM (SELECT DISTINCT TYPE,DataSourceGroupID,EQID,LRUID,DataFieldID FROM
EquationDataPresort) EquationDataPresort
LEFT OUTER JOIN DataSource ON (DataSourceGroup.DataSourceID = DataSource.DataSourceID)
WHERE LRU.LRUID = '406' AND EquationDataPresort.`DataSourceGroupID` > -1 AND
EquationDataPresort.EQID = '-1' GROUP BY LRU.InstanceDesc
我想订购DataSource.Name。我怎么能这样做?
由于
答案 0 :(得分:2)
连接元素的顺序是任意的。
如果您从行已经具有正确顺序的子查询中获取值,您可以希望保留订单:
SELECT lru,
GROUP_CONCAT(data_source, '@') AS data_source
FROM (SELECT LRU.InstanceDesc AS lru,
DataSourceGroup.DataSourceGroupID||'~'||... AS data_source
FROM ...
LEFT OUTER JOIN ...
WHERE ...
ORDER BY 1, 2)
GROUP BY lru