sql语句中两个数相除
select(selectcount(RecordID)fromRegisterRecordwheredatediff(yy,WBirthday,getdate())>2...
select (select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26)/(select count(RecordID) from RegisterRecord )*100
from RegisterRecord
结果为什么是 0
注意:1 、select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26 结果是2
2、select count(RecordID) from RegisterRecord 结果是5
3、select distinct
比例(%)=((select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26)/(select count(RecordID) from RegisterRecord ))
from RegisterRecord
这样写又为什么会出错 展开
from RegisterRecord
结果为什么是 0
注意:1 、select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26 结果是2
2、select count(RecordID) from RegisterRecord 结果是5
3、select distinct
比例(%)=((select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26)/(select count(RecordID) from RegisterRecord ))
from RegisterRecord
这样写又为什么会出错 展开
2013-07-13
展开全部
整数除以整数=整数改为:select 1.0 * (select count(RecordID) from RegisterRecord where datediff(yy,WBirthday,getdate())>26) /(select count(RecordID) from RegisterRecord )*100 As 比例(%)
from RegisterRecord
还有就是数据库字段的别名写法不是那样写的
from RegisterRecord
还有就是数据库字段的别名写法不是那样写的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询