views:

597

answers:

2
A: 

Here's an idea... Use the Pivot Keyword... available in sql2005

Pivot and UnPivot

Then after you have this working, outputting the column names as data values, embed this entire sql statemnt as the subquery inside an outer Select statement, where you Alias the column names as "Language1", "Language2" etc...

Select Z.Arabic as Language1, Z.Botwanese as Language2, etc.
From  (Inner Pivot Query Here ) Z
Charles Bretana
Sorry, but I am having difficulty understand how to use PIVOT to get those columns as the columns are not fixed to a particular Lanaguage in this case.
BlackMael
+1  A: 

You can use the PIVOT() function

SELECT    P.PRODUCT_ID,
          P.Czech,
          P.Other languages
FROM      TABLE AS T
PIVOT     (
              AGGREGATE(LANGUAGE) FOR LANGUAGE IN ([Czech],  ...)
          ) AS P

If you don't name the columns explicitly you are forced into doing tricks as far as I know...

Untested (obviously). See: MSDN

Scott
This looks like it pivots on specific language. I want LANG_1, LANG_2, LANG_3. Which column a language falls under is irrelevant.
BlackMael