Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

structure result in sql query

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi

I have a database table that contains theese columns...

Name Language Trans Description

Book 1 US Y US Book
Book 1 GB Y GB Book
Book 1 ES Y ES Book
Book 2 US Y US Book
Book 2 GB Y GB Book
Book 2 ES Y ES Book

I would like to query the DB so I get a result that look like this...

Name US GB ES
Book 1 US Book GB Book ES Book
Book 2 US Book GB Book ES Book


Could someone please show me how I can achive this?


Regards


 
You need to use a crosstab query.
Code:
select Name,
   max(case when Language = 'US' then Description end) 'US',
   max(case when Language = 'GB' then Description end) 'GB',
...
from table
group by Name
There are lots of examples in the forums.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
Donate to Katrina relief
 
Hi Denny


That worked just perfect, thanks a lot for the help!


Best Regards


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top