Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
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 July 21st, 2004, 08:13 PM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default HELP - Combine Rows in a View

Hi All,

I know how to do this in Access, using VB, but I'm pretty new to SQL Server and have no idea how to even start.

Say you have a table, call it TblStudents, with two columns: Grade and Name. Then, say you want to write a view that groups the students by grade, so you know who got an A, etc, with each grade in one row.

So you start with the table looking like this:

Grade Name
A John
A Lisa
A Pat
B Fred
B Tina
C David
C Greg

And you want a view that gives a dataset looking like this:

Grade Name
A John, Lisa, Pat
B Fred, Tina
C David, Greg

How do you do this? It looks easy enough, but I've checked a couple of SQL Server books and online and while the question has been asked several times, I can find no clear answers.

Thanks.

Henry


 
Old July 22nd, 2004, 12:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

This has been discussed manytimes in this forum. Take a look at this thread.

Concatenating like records

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Rows to Grid View dpkbahuguna ASP.NET 1.x and 2.0 Application Design 0 March 19th, 2008 04:05 AM
Combine Multiple Rows into One Row eusanpe SQL Language 3 November 13th, 2007 01:25 PM
Moving rows in Datagrid view control in C# Bob337 General .NET 0 June 9th, 2007 10:13 AM
populate details view or list view non empty rows iinfoque ASP.NET 2.0 Basics 0 March 11th, 2007 06:11 AM
alternative rows in diff. colours for list view madhukp VB How-To 2 October 7th, 2004 07:12 AM





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