Click here to Skip to main content
14,641,343 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

Use present < 0.75 * (present+absent) for 75% attendance.
present < absent would be 50% criteria.
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try this one

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
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

try this,

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

............
@Nidhish
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100