Ask the Expert

Returning one row with as many colums as there are attributes

I have a table with product attributes with one row per product per attribute (ie, if product 1 has three of the possible attributes, there are three rows for product 1 and if product 2 has no attributes there are no rows for product 2). How can I write a select query that returns only one row per product, but as many columns as there are attributes? Thanks!

    Requires Free Membership to View

I answered a similar question just last week. Because my response was fairly lengthy, as I offered five separate possible solutions, I will simply refer you to the answer entitled, "Listing data from multiple rows," which was posed on 30 January 2002.

For More Information

  • What do you think about this answer? E-mail the edtiors at editor@searchDatabase.com with your feedback.
  • The Best SQL Web Links: tips, tutorials, scripts, and more.
  • Have an SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your technical SQL questions -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

This was first published in February 2002

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.