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
 SQL Server Development (2000)
 How to display data in Columns from a row

Author  Topic 

wagau999
Starting Member

5 Posts

Posted - 2008-11-06 : 06:13:28
Hi there,
i am using SQL Server 2000 and T-sql
I have a report i want to create which will show me infomation like the following:

LoginID , Start_Date, End_Date and Total Time

However all this information is heald in one table but the info comes like this
LoginID Start_Date End_Date Total Time
1 12-04-07 00:10:00 12-04-07 00:20:00 10
1 12-04-10 01:10:10 12-04-10 00:20:00 30
2 12-04-07 00:10:00 12-04-07 00:20:00 10
2 12-04-07 02:10:00 12-04-07 00:20:00 10
2 12-04-07 03:10:00 12-04-07 00:20:00 10
3 12-04-07 04:10:00 12-04-07 00:20:00 10

Now i would like to see the data like this in a linear fashion:

'First row' 1 12-04-07 00:10:00 12-04-07 00:20:00 12-04-10 01:10:10 12-04-10 00:20:00 40
'Second row' 2 12-04-07 00:10:00 12-04-07 00:20:00
12-04-07 02:10:00 12-04-07 00:20:00
12-04-07 03:10:00 12-04-07 00:20:00 30

However differnt Loginid will have different Start_Date and End_Date of data in it so some may have 5 rows othere could have ten?
is this possiable ?


Thank you
Gaurav


"A successful man is one who can lay a firm foundation with the bricks others have thrown at him."

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-11-06 : 06:16:14
You are better doing this in whatever front end app you are using (if you are using one) That said there are many many posts on this site for pivoting info. Just look for rows to columns. etc


IN 2005 this would be a lot easier to do with TSQL as you have the PIVOT operator.



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -