Question : Computed Column - Adding to current code

I currently have a computed column that checks for youth that turn 18 during the month.  I have the code below as you can see.  If a youth turns 18 the computed column returns a value of 3.

However, I need to ADD more to this code.  Each student in the table also has a column called "TotalHours" and "Month"  Every month of the year there is a new record for every student.  January through December.  And each of those records should have hours in the "TotalHours" column.  

If a student has 0 hours for three months in a row, then the computed column should return a value of 3 also for this case.

Is this possible?  Can I do it in an OR statement below?
Code Snippet:
1:
2:
3:
4:
5:
6:
( case when ( datediff( month, dateadd(year,(-18),getdate()), [Text7] ) <= 0 )
then (3) else [Combo1] end )

OR

'code for the 3month check goes here...

Answer : Computed Column - Adding to current code

the problem is that you have X records per student, and you cannot have a computed column see at another table.

I would suggest you create a regular column in the table, and keep that updated with triggers on the other table, so that when there are 3 records in a row as indicated, that additional column gets changed from 0 to 1, for example (or back, if there are no longer 3 records in a row ...) and have your computed column look at that column ...
Random Solutions  
 
programming4us programming4us