October 16, 2009 at 3:41 am
hi friends
hi have one table
id date
1 2009-01-01
1 2009-02-01
2 2009-01-02
3 2009-04-01
2 2009-04-21
1 2009-04-08
1 2007-04-04
4 2007-04-04
i need resuld in
id date1 date2 date3 date4 date5 date6
1 2009-01-01 2009-02-01 2009-04-08 2007-04-04
2 2009-01-02 2009-04-21
3 2009-04-01
4 2007-04-04
i thought to use top clause but permorance issue
so please any one hepl me
October 16, 2009 at 8:08 am
Take a look at the article in my signature on cross tabs. If you need more help writing the code, please post table definitions and sample data according to the "How to post Sample Data" article that is also in my signature.
October 18, 2009 at 11:08 pm
please check this
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[test](
[id] [int] NULL,
[date] [datetime] NULL
) ON [PRIMARY]
insert into test
select 1,'2009-01-01' union all
select 1,'2009-05-01' union all
select 2,'2009-04-01' union all
select 2,'2009-01-01' union all
select 3,'2009-01-01' union all
select 1,'2009-04-01' union all
select 3,'2009-03-01' union all
select 2,'2009-02-01' union all
select 4,'2009-01-01' union all
select 1,'2009-05-01'
Result should be
iddate1date2date3date4date5
11-Jan-091-May-091-Apr-091-May-09null
21-Apr-091-Jan-091-Feb-09nullnull
31-Jan-091-Mar-09nullnullnull
41-Jan-09nullnullnullnull
please give solution
October 19, 2009 at 8:16 am
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply