A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
I've got a table with 2 columns: colA int, colB varchar. The data in this table is as follows
Can anyone help me write a query that will output 2 rows like this:
11 red, blue, green
22 square, circle
Any help with this one would be muchly appreciated.
I can't think of a way to do it in plain SQL. Since you asked specifically for a T-SQL solution, there probably is a specific, proprietary database function that will concatenate all records (matching a criteria) together as a string.
The easiest thing to do, of course, is wait for someone to give you the answer. The second easiest thing to do is find a list of all proprietary functions for your database (example: if you were using Oracle, check your PL/SQL Programming reference book) and just look for one that sounds like it might do what you're trying to do.
Sorry about the answer - like j said, this sounds suspiciously like a homework problem, and the real value is that it teaches you to look stuff up as opposed to solving the puzzle itself.
Wednesday, October 18, 2006
For what it's worth, this is not a homework question. I've given a very simplified example so that the complexities of my specific situation don't prevent people from being able to help me with the crux of the problem.
If you're just going to tell me to do my own homework, why bother commenting at all?
Some solutions for MS SQL Server 2005:
You can do this with COALESCE.
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz