查询以计算默认值 [英] query to calculate defaulters

查看:83
本文介绍了查询以计算默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请帮助我形成查询,以计算给定月份的默认学生人数.如果学生的出勤率低于75%,则它是默认学生.
表结构如下:
1> int record_no(主键)
2> int年
3> varchar sem
4> varchar stuid(学生证)
5> int subid(主题ID)
6> varchar类型(理论/实践)
7> int存在(无天数)
8> int缺席(无天数)
9> int工作(总天数)
10> varchar月

我已经编写了此查询,但逻辑错误:

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

推荐答案

使用present < 0.75 * (present+absent)出席75%.
present < absent将是50%的标准.
Use present < 0.75 * (present+absent) for 75% attendance.
present < absent would be 50% criteria.


尝试这个

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


尝试一下,

从出勤1中选择stuid,present,absent,working,[type],其中((present * 100)/working)< 75

............
@Nidhish
try this,

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

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


这篇关于查询以计算默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆