Presuming attendee is just a name here is a simple approach.
<cfquery name="q1" datasource="myDSN">
Select count(attendee) as currentAttendees
>From EventAttendance
Where eventide = <cfqueryparam cfsqltype="cf_sql_integer"
value="#eventId#" />
</cfquery>
<cfquery name="q2" datasource="myDSN">
Select max
>From Events
Where eventide = <cfqueryparam cfsqltype="cf_sql_integer"
value="#eventId#" />
</cfquery>
<cfif q1.currentAttendees gte q2.max>
<cfoutput>Full Event</cfoutput>
<cfelse>
<cfoutput>#q2.max#-#q1.currentAttendees# spots left</cfoutput>
</cfif>
This could also be done with joins and group bys if you have several events
but it's hard to just type it out without seeing the data.
Paul.
-----Original Message-----
From: Adam Parker [mailto:[email protected]]
Sent: Friday, March 06, 2009 2:40 PM
To: cf-newbie
Subject: Find Maximum
Hello -
I am trying to determine if the maximum number of attendees has been met for
an event. In one table, the maximum attendance allowed is set. In another
table, the attendees are captured as well as the event id.
The relation is:
Events
-id *
-max
EventAttendance
-eventID *
If the total of eventIDs is greater than or equal to the event max, I want
to display the event is full to the user on the list of upcoming events.
Can any suggestions be provided?
Thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4426
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15