Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql - output not in as rows but as cols

Status
Not open for further replies.

ani77

Programmer
Oct 4, 2002
14
IN
Hello,

I have a table CLIENTS which stores name and other details of all the clients.
Columns are Client_Id, Name.
Suppose data is
1 ABC
2 XYZ
3 PQR
Table TRANSACT stores transactions done with the clients.
Its Columns are Transact_id, Client_id and Date
For a client there can be more than one transaction.
Primary key is Transact_id
1 1 12/12/02
2 2 13/12/02
3 1 13/12/02

From my sqlquery i want to list Distinct Client names Vertically and Transaction done date horizontally.
Like this -
ABC 12/12/02 13/12/02
XYZ 13/12/02

Kindly guide.

regds
ani77
 
Thanks Terry

I was aware that there was something in Sqlserver for this.
Something that starts with Cross..
But was getting confused with CrossJoin.
Since not in touch with sqlserver I forgot.

Anyways thanks a lot!!
:)

ani77
 
Hello, my name is Rachman.
Now, i'm member this forum and i want to solve your problem for that case.
I think you can use variable memory and declare become more than 1 variable to save your data.

Example
First, looping your data and save to variable memory.
 
SQL Server does not have a Crosstab query like Microsoft Access. However, Crosstab results can be achieved using various techniques. That is why I recommend reading other threads about crosstab queries so you may become acquainted with those techniques.

thread183-392875, thread183-423782 Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
No... never with a single SQL Query...

All the Best
Praveen Menon
pcmin@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top