[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

SQL SUM to control DataList item display

Asked by John0214 in Programming for ASP.NET, SQL Query Syntax, VB Script

Tags: ASP.NET, VB, MS SQL Server, DataList, SUM

ASP.NET, VB, MS SQL Server

I have a DataList that displays available training sessions to our clients. Each training session is made up of 5 different modules. Each module has a limit of 12 attendees, for a potential 60 attendees for a particular training session.  Once we reach the limit of 60 attendees, we want the particular training session to NOT appear in the DataList.  The other consideration is an expiration date for each training session, which is working fine. I only mention it because it is part of the code I have submitted below.

I have three SQL tables: one for the training location information (mutliple locations), one for the actual training sessions, and another for attendee/registrant information.

When a person clicks on the training session listed in the DataList, it brings them to a detailed page where they can select the individual training modules for that training session. When the person registers, a value of either '0' (not selected) or '1' (selected) is inserted for the particular training modules in the registrant database table. In addition, the training session's sessionID is inserted into a table column as well.

What I'm trying to do:
When the page loads, I want the DataList to SUM the 5 different modules per sessionID saved in the registrant database (which may be Null if nobody has registered for any modules within a training session). If the SUM of all 5 modules associated with the same sessionID is equal or greater than 60, don't display the training session.

Code below. Note the variables productID, trainingID and expDate are select parameters.

Thank you for any assistance or insight - I need the help and am not sure this approach is the best one.
1:
2:
3:
4:
5:
6:
7:
SELECT ts.productID, ts.trainingCatID, ts.sessionStartDate, ts.officeID, ts.sessionID,  ts.sessionEndDate, tl.officeCity, tl.OfficeState, isNull(SUM(tr.module1), 0) + isNull(SUM(tr.module2), 0) + isNull(SUM(tr.module3), 0) +isNull(SUM(tr.module4), 0) + isNull(SUM(tr.module5), 0) As WeekTotal
 
FROM TrainingLocations tl, TrainingSessions ts LEFT JOIN TrainingRegistrants tr ON ts.sessionID = tr.sessionID
 
WHERE (ts.productid = @productID AND ts.trainingID = @trainingID AND ts.officeID = tl.officeID AND expDate > @expDate AND WeekTotal < 60)
 
GROUP BY ts.productID, ts.sessionID, ts.trainingCatID, ts.sessionStartDate, ts.sessionEndDate, ts.officeID, tl.officeCity, tl.officeState, tr.module1, tr.module2, tr.module3, tr.module4, tr.module5
 
Related Solutions
Keywords: SQL SUM to control DataList item display
 
Loading Advertisement...
 
[+][-]11/04/09 02:02 PM, ID: 25744467Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, SQL Query Syntax, VB Script
Tags: ASP.NET, VB, MS SQL Server, DataList, SUM
Sign Up Now!
Solution Provided By: samtran0331
Participating Experts: 2
Solution Grade: A
 
[+][-]11/04/09 05:29 PM, ID: 25745983Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 04:37 AM, ID: 25748765Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 06:05 AM, ID: 25749516Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 06:43 AM, ID: 25749900Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 07:34 AM, ID: 25750550Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625