SQL question 
Author Message
 SQL question

I have one interesting problem that I don't know how to resolve.
I need to create a view for one of the tables that should do the
following:
The query returns 3 colums.
X   Y   Z
-   -   -
A1  A2  1
A1  A2  3
A1  A2  5
B1  B2  2
B1  B2  3
B1  B2  8

I need to show them as
A1  A2  1,3,5
B1  B2  2,3,8

I tried various combinations but couldn't make it work.
If anyone can give me a clue, I will appreciate it very much.
Thanks.



Sun, 31 Oct 2004 10:02:09 GMT
 SQL question

Quote:

> I have one interesting problem that I don't know how to resolve.
> I need to create a view for one of the tables that should do the
> following:
> The query returns 3 colums.
> X   Y   Z
> -   -   -
> A1  A2  1
> A1  A2  3
> A1  A2  5
> B1  B2  2
> B1  B2  3
> B1  B2  8

> I need to show them as
> A1  A2  1,3,5
> B1  B2  2,3,8

> I tried various combinations but couldn't make it work.
> If anyone can give me a clue, I will appreciate it very much.
> Thanks.

I don't think it is possible to resolve this in a single query (to
make a view). But it can be done in a stored procedure (with a
helptable) for sure. I mail you a SQL-script who does the work.


Sun, 31 Oct 2004 16:22:01 GMT
 SQL question
Try this

SELECT x, y, LIST(z)
FROM MyTable
GROUP BY x,y

Hope it helps
Boaz Ben-Porat



Quote:
> I have one interesting problem that I don't know how to resolve.
> I need to create a view for one of the tables that should do the
> following:
> The query returns 3 colums.
> X   Y   Z
> -   -   -
> A1  A2  1
> A1  A2  3
> A1  A2  5
> B1  B2  2
> B1  B2  3
> B1  B2  8

> I need to show them as
> A1  A2  1,3,5
> B1  B2  2,3,8

> I tried various combinations but couldn't make it work.
> If anyone can give me a clue, I will appreciate it very much.
> Thanks.



Mon, 01 Nov 2004 02:33:11 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Access question -> SQL question

2. Update question and SQL question

3. Simple SQL Question for the SQL Gurus

4. SQL question (not really sql server programming)

5. SQL Gurus: Time SQL question

6. SQL Server T-SQL Question

7. SQL Question: Best way to pass array data to SQL Server

8. SQL question for SQL Gurus

9. more dynamic SQL-Server SQL question

10. ms-sql sql question, isnull function

11. SQL Q: Everybody loves a good SQL question


 
Powered by phpBB® Forum Software