Reputation: 73
I have following table of students
Attendance is of the month of November 2011
date absentperiod name
2011-11-01 1 x
2011-11-01 5 x
2011-11-01 5 y
2011-11-01 1 z
How to write sql
query to find status? I am doing it in php.
I want to get output for employee x - absent
, y - half day
, z- half day
Students absent in period 1 and 5 should be absent Students absent in period 1 or 5 should be HALF DAY
Upvotes: 0
Views: 1141
Reputation: 39507
Try this:
select date,
first_period,
fifth_period,
name,
case when first_period != fifth_period
then 'Half day'
else first_period end status
from my_table;
Upvotes: 2