 |
| 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
|
|
|
|

May 4th, 2004, 03:21 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Query Direction??
I looking to write a query in TSQL that instead of listing my results as follows;;
Number Company Contact
00001-005 ABC Inc. Jones, Joey
00001-005 ABC Inc. Doe, John
00001-005 ABC Inc. Rubble, Barney
instead would list the results like this if the "Number" is the same.
Number Company Contact1 Contact2 Contact3
00001-005 ABC Inc. Jones, Joey Doe, John Rubble, Barney
Is it a cross tab query or do i make use of cursors, or derived tables. Just looking for direction. will do the leg work once i get the right path. Thanks, bph
|
|

May 5th, 2004, 05:58 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
do you have an identity column for each row?
|
|

May 11th, 2004, 08:01 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by jemacc
do you have an identity column for each row?
No. Don't need it.
|
|
|

May 11th, 2004, 08:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You can use the "GROUP BY" Sql statement. Check Books online.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

May 11th, 2004, 08:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Wait- on second thought.. no.. that won't work. You would need to create a DISTINCT query that would get a list of the "number" column and then do a join to that of the data. The problem is, I assume, there can be any number of rows that need to be joined. Rather than always being three. The best way to do this is probably in a business object. That's how I would do it.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

May 11th, 2004, 08:46 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Hal Levy
Wait- on second thought.. no.. that won't work. You would need to create a DISTINCT query that would get a list of the "number" column and then do a join to that of the data. The problem is, I assume, there can be any number of rows that need to be joined. Rather than always being three. The best way to do this is probably in a business object. That's how I would do it.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
Thanks Hal. BO is currently beyond my set of skills. I'm going to take a look at SQL Smarties by Joe C.
|
|

May 11th, 2004, 09:12 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Do you write VB? C++ or any .net language?
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

May 11th, 2004, 09:45 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Hal Levy
Do you write VB? C++ or any .net language?
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
vb.net
|
|
 |