943,199 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 462
  • ASP RSS
Jun 25th, 2010
0

Structure of for loop

Expand Post »
I have a list of questions, each has its own category. I want to be able to select 5 random questions from each category and then display them ordered by category in something like a nested repeat region. I have the sql for obtaining the random 5 for each category but I would like to pass this category as long as there is a category to get this dataset all at once, rather than one page for each category as I have right now. Basically:
For each B]CATEGORY VALUE[/B] in select B]CATEGORY VALUE[/B] from TA_BusMetricsDef

SELECT TOP (5) dbo.TA_Questions.TA_QId, dbo.TA_Questions.TA_Question, dbo.TA_BusMetricsDef.TA_BusMetricDescript, dbo.TA_Questions.TA_BusMetricName
FROM dbo.TA_Questions
INNER JOIN dbo.TA_BusMetricsDef ON dbo.TA_Questions.TA_BusMetricName = dbo.TA_BusMetricsDef.B]CATEGORY VALUE[/B]
WHERE dbo.TA_Questions.TA_BusMetricName = dbo.TA_BusMetricsDef.CATEGORY VALUE(PASSED BY THE FOR LOOP)

Can someone help me structure this appropriately using the right syntax so I can get results? Thanks!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pinkiguana is offline Offline
4 posts
since Jun 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: File upload
Next Thread in ASP Forum Timeline: How to Parse XML in ASP?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC