views:

192

answers:

2

I've got these columns [in a single table]:

partnumber
bin
description
store 
manufacturer

I need to output the store and manufacturer as rows for each partnumber, bin, description column.

+1  A: 

Perhaps using a pivot or group by?

Your question is very vague, doesnt show much of table structure and doesnt list the RDBMS that you are using.

Consider editing your tags to include SQL, the database server you are using?

Matt

Lima
A: 

If my rewrite of the question is approximately correct, then it is still vague, but one possible interpretation of the required output is given by:

SELECT "store" AS tag, store        AS name, partnumber, bin, description
    FROM TheAnonymousTable
UNION
SELECT "maker" AS tag, manufacturer AS name, partnumber, bin, description
    FROM TheAnonymousTable

This gives the store as a row and the manufacturer as a row for each partnumber, bin and description combination. And UNION, by default, eliminates duplicates. This is not an example of pivoting.

The chances are that this is not what is required - but the question should be revised to ensure that:

  1. The table has a name.
  2. The required output is explained more clearly.
  3. Ideally, the question includes some example input data (for the table) and sample output results.
Jonathan Leffler