Isn't there any way to do this via JSTL and not in the DB query? My example was rather simplistic for what I'm really doing, but still is a good example of the raw data. I'm using the resulting number in colspans and rowspans to build a nicer table layout (displaying data only once that's repeated for several rows). I was trying to avoid sub selects and such because I have anywhere from 30 and up columns that I'm returning and having to store a separate count variable for each one is getting ridiculous. I really do appreciate your time in replying, though!
Keith ---------- Original Message ----------- From: David Schwartz <[EMAIL PROTECTED]> To: "'Tag Libraries Users List'" <[EMAIL PROTECTED]> Sent: Thu, 15 Apr 2004 14:23:03 -0400 Subject: RE: Conditional Loop > Try a sub select that returns the count... > > SELECT > > t.Primary_Key, > h.Name, > (Select Count(tt.Name) as Count_Name > FROM myTable tt > where tt.Name = t.Name > ) > FROM myTable tt > > It's fast & returns all nesc data from the db. > > David Schwartz > > -----Original Message----- > From: Keith [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 15, 2004 1:45 PM > To: Taglibs > Subject: Conditional Loop > > Here's a generic scenario similar to my situation: > > A database with two columns, one being an auto-sequence number for the > primary key, the > other listing names. > > 1 Bob > 2 Bob > 3 Jim > 4 John > 5 Jim > 6 Bob > 7 John > 8 John > 9 Jim > 10 Bob > > Ok, I query the database to return both columns, since I need all the stored > data. But I > also want to get the number of each unique name in the 'names' column (how > many Jim's, > how many Bob's, and how many John's). I know I could do a separate query > looking for a > count() on each unique name, but that's not realistic with the amount of > data I'm dealing > with (actually tried doing it and nearly killed the poor DB server). > > Normally, I'd do this with a 'while' conditional loop and a counter > incrementing while > the 'name' column contains a specific value, but I don't see that > functionality in JSTL. > I had asked generally before if JSTL had any 'while' loop capability, but > got no > response. So, I figured I'd give an example of what I'm trying to do and > maybe someone > could help. > > Thanks! > > Keith > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] ------- End of Original Message ------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]