Wednesday, March 21, 2012

GROUPBY ??

I have a table with two columns item_code and Alternate_reference. During a
select I would like to concatenate Alternate_reference if there are more tha
n
one for an Item_code. Is this possible and if so how do you accomplish this.
Here is and sample of the data
Item Code Alternate_reference
123456 85694
123456 86623
123456 25364
The resulting value
Item Code Alternate_reference
123456 85694, 86623, 25364See if this helps:
http://groups-beta.google.com/group...
5bf366dd9e73e
AMB
"Sherry" wrote:

> I have a table with two columns item_code and Alternate_reference. During
a
> select I would like to concatenate Alternate_reference if there are more t
han
> one for an Item_code. Is this possible and if so how do you accomplish thi
s.
> Here is and sample of the data
>
> Item Code Alternate_reference
> 123456 85694
> 123456 86623
> 123456 25364
>
> The resulting value
> Item Code Alternate_reference
> 123456 85694, 86623, 25364|||Sherry, I've needed to do something like this for user display purposes
and I've done it in application/script code. Very simple loop and
concat operation. Probably not as simple in SQL, so if you can do it
client-side you'll be better off.|||Thanks Alehandro...I'll look it over.
"Alejandro Mesa" wrote:
> See if this helps:
> http://groups-beta.google.com/group...d85bf366dd9e73e
>
> AMB
> "Sherry" wrote:
>|||Alejandro and Sherry have giving you the correct answer but let me repeat
it.
Do this client side.
Reasons:
Databases are not built to do this efficiently (it's not their job).
It's simple to do this client side.
Your application will possible (probably) be faster if you do this client
side.
I tested the last point out myself and the speed-gain was remarkable.
YMMV
"Sherry" <Sherry@.discussions.microsoft.com> wrote in message
news:65EF5552-90E1-4122-990D-B27E4BD8225D@.microsoft.com...
>I have a table with two columns item_code and Alternate_reference. During
>a
> select I would like to concatenate Alternate_reference if there are more
> than
> one for an Item_code. Is this possible and if so how do you accomplish
> this.
> Here is and sample of the data
>
> Item Code Alternate_reference
> 123456 85694
> 123456 86623
> 123456 25364
>
> The resulting value
> Item Code Alternate_reference
> 123456 85694, 86623, 25364

No comments:

Post a Comment