ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 15th, 2002, 11:24 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
Post Grouping Results in ASP using SQL

Is there a way to use a SQL statement in an ASP page to group results by one field (using group by and do while/loop). For example, say I was trying to group courses by students. I would like to display the information like this:

John Smith
Biology Fall 2002
Sociology Spring 2003
Chemistry Fall 2002

Jack Jones
Biology Spring 2003
Psychology Fall 2002

When I write the code, I get:

John Smith Biology Fall 2002
John Smith Sociology Spring 2003
John Smith Chemistry Fall 2002
Jack Jones Biology Spring 2003
Jack Jones Psychology Fall 2002

Reply With Quote
  #2  
Old April 16th, 2002, 10:31 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
can you post the setup of your database so that i can work out a tsql query for you please?

Reply With Quote
  #3  
Old April 16th, 2002, 10:57 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
Thanks. I'm using Access

tbl_Courses

CourseID - Number (Primary Key)
CourseName - Text
Session - Text

tbl_Students

StudentID - Number (Primary Key)
StudentLastName - Text
StudentFirstName - Text

tbl_StudentCourses

StudentID - Number (Primary Key)
CoursesID - Number (Primary Key)

(I know I should probably put the session in a separate table, but this is just a sample. I'm just trying to figure out how to get the student name once, followed by a listing of the course names ). If I could see how the SQL statement would work in this instance, I can hopefully apply it to more complex and (properly constructed) relational database.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Grouping Results in ASP using SQL


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap