Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Lono
Starting Member
2 Posts |
Posted - 2007-11-20 : 19:32:23
|
| Hello,I have been trying to write a query for a few hours (sorry, I am a newbie to sql server) and it is not happening for me. If someone could point out some links to articles or examples online or offer some help I would greatly appreciate it.I have inherited a database that is probably not set up correctly (as far as the table structure), but I cannot do anything about that now.Here are three tables that I need to query: People PeopleID FirstName LastName ....and some other attributes which are not in my query. PeopleSkills PeopleID SkillID Skills SkillID SkillDescSo, people have can one or multiple rows in the PeopleSkills table. And what I want to do, because this needs to be output for a report, is to generate a single row per user and ALL of their skills. There are only 3 or 4 skills I need to filter on (in my where clause).What I want to end up with is something like this: PeopleID | Name | SkillDesc1 | SkillDesc2 | SkillDesc3where I would use the AS to create an Alias for each skill type being selected.What I end up with is multiple rows, like this: PeopleID | Name | SkillDesc PeopleID | Name | SkillDesc PeopleID | Name | SkillDesc PeopleID | Name | SkillDesc Again, if someone could point out an online article or something that would get me started in the right direction, I would be grateful.Thank you, bill |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-20 : 21:07:52
|
use the PIVOT function to do it. Check out Books Online on this KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Lono
Starting Member
2 Posts |
Posted - 2007-11-20 : 23:13:08
|
| Thank you, I'll check out the Pivot stuff now. |
 |
|
|
|
|
|
|
|