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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Query question

Author  Topic 

dcarva
Posting Yak Master

140 Posts

Posted - 2005-04-01 : 17:58:58
Hello,

I have a query that, due to a join, returns records like this:

[Machine] [value1] [value2]
[M1] [y]
[M1] [x]


Using a single T-SQL query, how can I query it so that it returns:

[Machine] [value1] [value2]
[M1] [x] [y]

I have seen this done before, I just can't find any examples. Thanks!!!

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-04-02 : 03:22:01
Hi there,
post the table structure and maybe som sample data.
That will make this go faster.

What You are after is a crosstab (or pivot) query.

rockmoose
Go to Top of Page

dcarva
Posting Yak Master

140 Posts

Posted - 2005-04-02 : 09:55:50
Thanks! I looked up "crosstab" and "pivot" table. I found good examples. Thanks again!
Go to Top of Page
   

- Advertisement -