Wednesday, March 28, 2012

Query Problem

Dear All,
I have a problem about creating a view to concat all the row field
together.
For example I have a table with 2 columns
ColA, ColB
1 , A
1 , B
2 , A
2 , B
2 , C
I want to make a view using group by and the excepted view should return
ColA, ColB
1 , A-B
2 , A-B-C
Thanks for your help.
^_^You have to use Aggregate Function with Group By and since no existance sql
function to do so.. Then you have to write one by yourself, or do it in your
application
for me C# code is easier than TSQL
<Windy> wrote in message news:%233DyE7vMGHA.3708@.TK2MSFTNGP09.phx.gbl...
> Dear All,
> I have a problem about creating a view to concat all the row field
> together.
> For example I have a table with 2 columns
> ColA, ColB
> 1 , A
> 1 , B
> 2 , A
> 2 , B
> 2 , C
> I want to make a view using group by and the excepted view should return
> ColA, ColB
> 1 , A-B
> 2 , A-B-C
>
> Thanks for your help.
> ^_^
>|||On Thu, 16 Feb 2006 21:47:45 +0800, <Windy> wrote:

>Dear All,
> I have a problem about creating a view to concat all the row field
>together.
>For example I have a table with 2 columns
>ColA, ColB
>1 , A
>1 , B
>2 , A
>2 , B
>2 , C
>I want to make a view using group by and the excepted view should return
>ColA, ColB
>1 , A-B
>2 , A-B-C
Hi Windy,
See http://www.aspfaq.com/show.asp?id=2529.
Hugo Kornelis, SQL Server MVP

No comments:

Post a Comment