如何在SQLQuery中放置比率 [英] How To put Ratios in sqlquery
本文介绍了如何在SQLQuery中放置比率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友,
在这里,我想在sqlquery中查找比率.在我的项目中,我想在Perticular District实施学生和教职员的比率
所以我成功了:
我的输出:
Dear Friends,
Here i want to Find Ratios in sqlquery.In my Project i want to Implement Ratios of Students and staff in Perticular District
So iam sucess up to this:
My OutPut:
txtDistName intStaff intStudents
Zanzibar Urban 212130 168
所以现在我要显示intsatff和intStudents的比率
So now i wat to Display the ratio of intsatff and intStudents
txtDistName intStaffStudents
Zanzibar Urban 212130/100:168/100
所以我想要那份Coloumns的口粮
Iam发送我的示例查询:
So i want the rations of that Coloumns
Iam Sending my sample Query:
SELECT ntblDistrict_1.txtDistrictName, SUM(tblSummaryStudents.intMale + tblSummaryStudents.intFemale) AS intStudents,
SUM(tblSummaryOthers.intTeachersMale + tblSummaryOthers.intTeachersFemale) AS intStaff
FROM ntblDistrict AS ntblDistrict_1 INNER JOIN
ntblPrimarySchoolList ON ntblDistrict_1.intDistrictID = ntblPrimarySchoolList.intDistrictID INNER JOIN
tblSchool ON ntblPrimarySchoolList.intPrimaryListID = tblSchool.intPrimaryListID INNER JOIN
tblSummaryOthers ON tblSchool.intSchoolID = tblSummaryOthers.intSchoolID INNER JOIN
tblSummaryStudents ON tblSchool.intSchoolID = tblSummaryStudents.intSchoolID
WHERE (ntblDistrict_1.intDistrictID IN
(SELECT intDistrictID
FROM ntblDistrict AS ntblDistrict
WHERE (intDistrictID = 9)))
GROUP BY ntblDistrict_1.txtDistrictName
问候,
Anilkumar.D
Regards,
Anilkumar.D
推荐答案
select txtDistName, cast(intStaff/intStaff+intStudents) as decimal(20,2) as StaffRatio, cast(intStudents/intStaff+intStudents) as decimal(20,2) as StudentRatio from ...
这篇关于如何在SQLQuery中放置比率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文