SQLServerCentral » SQL Server 2005 General Discussion » How do I calculate this?InstantForum 2016-2 FinalSQLServerCentralhttps://www.sqlservercentral.com/Forums/SQLServerCentralTue, 17 Jan 2017 00:19:20 GMT20How do I calculate this?https://www.sqlservercentral.com/Forums/FindPost1457161.aspxI have a table called locations with fieldnames:
locationId --determines the location of trainee
locationName --name of the location training
maxSeat --total number of seats allowed at that location.
available_seats -- (MaxSeat - registered trainees)
My question is:
We would like to a button that says "Register" to substract a number from MaxSeat and "Cancel" to put back a number to MaxSeat.
In other words, when a potential trainee registers for a class, we would like to substract a number from maxSeat.
For instance, maxSeat is 45. If a trainee registers for that class, we would substract 1 from maxSeat.
Example: if maxSeat is 45 and a new trainee registers, we would like to see available seat as 44.
If another trainee registers, available seat should read 43, etc.
If a trainee decides to cancel a seat, this puts back a seat to availlable_seat so that it now goes up by one.
How can I code this?
Thanks a lotTue, 28 May 2013 06:50:21 GMTsimflex-897410RE: How do I calculate this?https://www.sqlservercentral.com/Forums/FindPost1457294.aspxThanks Jeff.Tue, 28 May 2013 06:50:21 GMTsimflex-897410RE: How do I calculate this?https://www.sqlservercentral.com/Forums/FindPost1457186.aspxCreate another value somewhere that is a copy of the MAX. Increment and decrement that with the idea that "returns" will never drive the number over the MAX and "draws" will ever decremet the number below 0.Mon, 27 May 2013 23:22:56 GMTJeff Moden