Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2007, 02:26 PM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crosstab or Union question

Hello all,
I want to retrive data from tblClient. I have fields trustid and Client name.

trustid ClientName
-------- ------------------
  1 John
  1 June
  2 Dave

I want above result to look like..

trustid ClientName
--------- --------------------
  1 John , June
  2 Dave

Is this possible?

Thanks for your help.

 
Old August 8th, 2007, 07:29 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

http://sqljunkies.com/WebLog/amachan...1/10/5065.aspx

--Jeff Moden
 
Old August 9th, 2007, 09:43 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

You can get this result. But there is no direct query for this. Read about cursors and use them. Or, use while loop in sql and temprary table.
 
Old August 10th, 2007, 01:53 AM
Authorized User
 
Join Date: Jul 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vksingh24
Default

try this

select trustid,COALESCE(ClientName) from tblClient group by trustid.

I hope it work.

__________________
Vikash Kumar Singh
 
Old August 10th, 2007, 04:12 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

Sorry Vikash, It wil not produce the desired result.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Crosstab Query Reporting Question darrenb Access 1 May 8th, 2007 06:24 AM
CROSSTAB Stella Evangelin Crystal Reports 1 September 8th, 2006 10:24 AM
crosstab yula Crystal Reports 1 August 31st, 2006 11:27 AM
crosstab s_a_ravi BOOK: Professional Crystal Reports for VS.NET 0 January 21st, 2005 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.