Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello all,
pls help me in forming the query to calculate the number of defaulter students for a given month. A student is a defaulter if his attendance is less than 75%.
The table structure is as follows:
1>int record_no (primary key)
2>int year
3>varchar sem
4>varchar stuid (student id)
5>int subid (subject id)
6>varchar type (theory/practical)
7>int present (no of days present)
8>int absent (no of days absent)
9>int working (total no of days)
10>varchar month

i have written this query but the logic is wrong:
select stuid,present,absent,working,type from attendance1 where year = '" + ddlyear.SelectedValue + "' and sem = '" + ddlsem.SelectedValue + "' and subid = '" + ddlsubid.SelectedValue + "' and month = '" + ddlmonth.SelectedValue + "' and present<absent
Posted

Use present < 0.75 * (present+absent) for 75% attendance.
present < absent would be 50% criteria.
 
Share this answer
 
v2
Try this one

SQL
SELECT
    `recordno`, `year`, `sem`, `stuid`,`subid`, `type`, ((100 / `working`) * `present` ) AS Percentage
FROM
    Students
WHERE
    ((100 / `working`) * `present` ) < 75
AND
    `month` = @SelectedMonth
AND
`subid` = @SelectedSubjectID;


This assumes that working is the total working days in the month, and that by inference, you calculate the percentage 100 divided by the total days, times the number of days attended (present).

Hope this helps
 
Share this answer
 
v2
try this,

select stuid,present,absent,working,[type] from attendance1 where ((present *100)/working )<75

............
@Nidhish
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900