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 2005 Forums
 Transact-SQL (2005)
 Transposing... I think.

Author  Topic 

Nesu
Starting Member

15 Posts

Posted - 2007-09-06 : 12:16:00
I have a query to produce a list of indicators that are by employee for each of the companies locations.

The indicators I produce are all in one table and when I produce them, they go down the page. What I'm trying to do is make the indicators go across the page.

ie, ind1 ind2, ind3, ... indx

I have included the code below that produces the indicators that go down the page in the outpage window, and could use some help in transposing them across the page so that i get each employees results acrros the page

Thanks very much.

Nesu.


select d.locatcode, d.locatname, c.deptcode, c.deptname, b.employeecode, a.indicator_id, a.numerator,
a.denominator, a.points from indicators as a
inner join employee as b on a.emp_id = b.emp_id
inner join deptnode as c on b.dept_id = c.dept_id
inner join locatnode as d on c.locat_id = d.locat_id
left outer join indicator as e on a.indicator_id = e.indicator_id
inner join indicator_group as f on e.indicator_group_id = f.indicator_group_id
where f.indicator_group_id = 1
order by 5, 6, 3

Kristen
Test

22859 Posts

Posted - 2007-09-06 : 12:18:31
Does using a cross tab help?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=More+Dynamic+CrossTabs

kristen
Go to Top of Page

Nesu
Starting Member

15 Posts

Posted - 2007-09-07 : 05:42:40
Thanks for the link.

I created the procedure and then executed it on the code as written above. It doesn't seem to return the rows as I wanted.
I still get, ignoring the location and dept for a moment,
employeecode indicator_id numerator denominator points
1 1 3 3 5
1 2 2 6 3
1 3 4 5 8

when what i was hoping for was
employeecode indicator_id numerator denominator points indicator_id numerator denominator points
1 1 3 3 5 2 2 6 3

so each employee only appears once with all their results in a row.

I'm really not sure what to do and could really use help if this is possible to do.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-09-07 : 05:45:40
Can you post the parameters you used for the Cross Tab Sproc please

Kristen
Go to Top of Page
   

- Advertisement -