l245c4l
l245c4l

Reputation: 4165

Concatenation of aggregate function and string attribute

Is it possible to do query like this:

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

Thanks,

Upvotes: 0

Views: 310

Answers (2)

DwB
DwB

Reputation: 38338

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.

Upvotes: 2

RichardTheKiwi
RichardTheKiwi

Reputation: 107826

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)

Upvotes: 2

Related Questions