sql数据获取的问题 [英] problem with sql data fetch
本文介绍了sql数据获取的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有问题要取数据
我的桌子是在表格中
rollno maxmark obtmark
1 100 60
1 100 70
1 100 70
2 100 65
2 100 80
但我发现outputr喜欢
rollno maxmark obtmark百分比
1 300 200 66.66
2 200 145 72.5
请帮帮我这个
解决方案
像这样的简单SQL应该让你非常接近你想成为。
选择 rollno,sum(maxmark) ,sum(obtmark),(sum(maxmark)/ sum(obtmark))* 100 as 百分比
来自 TABLENAME
group by rollno
dear sir/ma'am
i have a problem to fetch data
my table is in the form
rollno maxmark obtmark
1 100 60
1 100 70
1 100 70
2 100 65
2 100 80
but i found the outputr like
rollno maxmark obtmark percentage
1 300 200 66.66
2 200 145 72.5
please help me regarding this
解决方案
Simple SQL like this should get you pretty close to where you want to be.
select rollno, sum(maxmark), sum(obtmark), (sum(maxmark)/sum(obtmark))*100 as percentage from TABLENAME group by rollno
这篇关于sql数据获取的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文