String shenglv2="select user_name,sum(user_amount)/sum(amount) * 100 as rate,count(user_amount)/count(amount) as rate2 from bets where user_amount>0 group by user_name
解决方案 »
- 项目运行时出现HTTP Status 500 - 源文件在其他机器上好用。新装一台就出现错误,求教大侠
- 怎么把网络图片存到数据库?
- StrutsPrepareAndExecuteFilter中的问题
- 当 onclick 事件点击后正在下载图片就停止下载了
- 请教一下各位大侠
- JSP分页有点问题,帮忙看看
- 怎么样获取*每个*新闻类别下的前五条新闻????
- 请教JSP页面动态新闻点击率问题
- 在jb8里怎样配置serlet的开发包?
- 谁有无组件上传的例子,给我发一份!谢谢大家了!
- mysql启动不了,产生1069错误,高手解答下,谢谢。。。。
- commons-fileupload和tomcat5.0.16两个问题,解决后送200分
from bets
where user_amount>0
group by user_name
而不是count(user_amount)/count(amount)只统计user_amount>0.
select a.user_name,
sum(a.user_amount)/sum(amount) * 100 as rate,
sum(count_gt0)/sum(count_all) * 100 as rate2
from (
select user_name,
0 as user_amount, 0 as amount,
count(user_amount) as count_gt0, 0 as count_all
from bets where user_amount > 0 group by user_name
union all
select user_name,
sum(user_amount) as user_amount, sum(amount) as amount,
0 as count_gt_0, count(user_amount) as count_all
from bets group by user_name) a
group by a.user_name
select a.user_name,
sum(a.user_amount)/sum(a.amount) * 100 as rate,
sum(a.count_gt0)/sum(a.count_all) * 100 as rate2
from (
select user_name,
0 as user_amount, 0 as amount,
count(user_amount) as count_gt0, 0 as count_all
from bets where user_amount > 0 group by user_name
union all
select user_name,
sum(user_amount) as user_amount, sum(amount) as amount,
0 as count_gt0, count(user_amount) as count_all
from bets group by user_name) a
group by a.user_name
就是我看花眼了
这里好象是Java版吧?