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)
 select?

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-06-11 : 07:03:16
My data in tbl look like this:
ssn/Fname/LName
123/Bob/Jones
234/Tim/Brown
345/Mike/Simpson

I need the select query to give me this:
123/234/345
Bob/Tim/Mike
Jons/Brown/Simpson

How to do it?
Note: the /s are in there for dividing the columns.
I don't think this is a cross tab because no sum/avg/min on the body.
I remember I saw similar question somewhere, but could not find it.

Thanks!

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-11 : 09:45:23
Dare I ask why in the world would you do that????

If it is for some kind of web report, you are going about that the wrong way.

it would be a very specific query to translate the 1st result to the 2nd result. What would happen if you added a fourth row to the 1st result??

Let us know what you are trying to accomplish... then maybe we can help you better.

Corey
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-06-11 : 10:21:44
To answer your easy question first, if there are more rows on tbl1, then there will be more cols on the right for the result set.

The original report is in Excel, and the users are used to it in that way. I am rebuilding the report using grid in vb6 or .net. I have to get the data "right" either in the query, or when I bound it to the grid programatically.
Of cause, I can educate my users that the database way is the right way, they need to change their way of looking/working with the data. That will be my boss' job, and that will make me look less professional...
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-11 : 13:50:50
are you actually binding it to the grid or are you filling the grid in with the values you recieve??

you could do a getRows() (in ASP at least) and then just reverse your parameters... data(i,j) to data(j,i)

Other than that... I'm out.... REINFORCEMENTS!!!!

Corey
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-06-11 : 14:21:24
Yeah, that is what I am going to do.
I thought I saw a similar post somewhere on the web. I could not even find a key word to search for it.
Anyway, thank you for your time!
Go to Top of Page
   

- Advertisement -