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)
 SQL pivot or CASE dont know

Author  Topic 

karandhanu
Starting Member

2 Posts

Posted - 2010-03-11 : 14:26:51
Hi there i have two tables one is members table which give me Firstname, last name in rows and then i have event table which gives me dateStart(this is a column name) as datetime. and both of these tables are joined thru two other tables memberStatus and Season
Here is the details for each table
table member
has memberID(PK),firstname,lastname
table memberStatus
has memberStatusID(PK),memberID(FK),seasonID(FK)
table Season
has seasonID(PK)
table event
has eventID(PK), seasonID(PK),datestart(this is datetime format)

now what i am try to this write a query which can work in visual studio for ASP.NET
which give me firstname , last name as row and datestart as column
for example
right now this is what i get
fistname lastname datetime
john D march 1
John D march 2
john D march 3
mike s march 1
mike s march 2
mike s march 3

what i want is
fistname lastname datetime
john D march 1 march 2 march 3
mike s march 1 march 2 march 3

remember fistname and last name are coming out from one table (member)and datetime from an another table(event)

cda2007
Starting Member

17 Posts

Posted - 2010-03-11 : 18:41:29
This might help:
[url]http://it.toolbox.com/blogs/db2luw/pivot-query-12757[/url]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-12 : 11:46:53
see

http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -