开发者

Concatenation of aggregate function and string attribute

Is it possible to开发者_Python百科 do query like this:

select wm_concat(some_attribute1) || some_string_attribute || wm_concat(some_attribute2)
from SomeTable;

Thanks,


You should only be able to do that if there is a group by

select wm_concat(some_attribute1) || some_string_attribute || wm_concat(some_attribute2)
from SomeTable
group by some_string_attribute;

or if the 2nd part is also an aggregate

select wm_concat(some_attribute1) || max(some_string_attribute) || wm_concat(some_attribute2)
from SomeTable
group by some_string_attribute;

But I don't think it will work as you have shown since you are mixing aggregate with non-aggregate, akin to

select product, sum(price) from sometable

(i.e. which product since there is no group by)


Try this:

select
    wm_concat(attribute_the_first) colNameWon,
    the_agregation_attribute,
    wm_concat(attribute_the_second) colNameToo
from
    table_mien
group by
    the_agregation_attribute

If you get the results you want (in 3 columns), then the string concatination will give you what you seek.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜