SELECT multiple rows back as one row with many columns 
Author Message
 SELECT multiple rows back as one row with many columns
I'm querying a Key/Value table (Product_Id INT, Key VARCHAR(255), Value VARCHAR(255) NULL) and I want to return the Key/Value pairs in a single row for the specified Product_Id. What's the fastest way to do this?

Currently to get a key, I do something like:

What I want to see a row like:
Product_Id, Key [aliased to the Key and containing the value], [More Keys here]...

Is this even possible?



Fri, 28 Jul 2006 17:06:07 GMT
 SELECT multiple rows back as one row with many columns

hi jonC,

What you are looking for is dynamic crosstab, not possible with standard sql.
Refer to following url for some examples.

http://www.sqlteam.com/item.asp?ItemID=2955

--
Vishal Parkar



Fri, 28 Jul 2006 17:17:56 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. column in multiple rows to multiple columns in one row

2. column in multiple rows to multiple columns in one row

3. question regarding select (multiple rows select into one result row)

4. select case return rows in one row (how to group by three column)

5. Get values from multiple rows as attributes of one row

6. Moving multiple rows into one row

7. One source row to multiple destination rows

8. Combing multiple row data into one row in another table

9. Pivoting one source row into multiple destination rows

10. concatenate varchar field from multiple rows into one row as a group

11. selecting rows into one row

12. Grouping multiple rows into 1 row during a select into


 
Powered by phpBB® Forum Software