62,046
社区成员
发帖
与我相关
我的任务
分享
String sql = "select SerialID,count(1) as singel,count(1)/(Select count(*) from U_BreakDown a left join U_SerialNumber b on(a.SerialID=b.Code) left join U_ProcBatch c on(b.BatchID=c.Code) where c.ModelID='" + strModel + "' and BreakDownTime between '" + starttime + "' and '" + endtime + "' and ProductStageID='" + stageid + "') as percent
from U_BreakDown a left join U_SerialNumber b on(a.SerialID=b.Code) left join U_ProcBatch c on(b.BatchID=c.Code) where c.ModelID='" + strModel + "' and BreakDownTime between '" + starttime + "' and '" + endtime + "' and ProductStageID='" + stageid + "'
group by SerialID";
红字就是我要查的数据,绿字和后面的红字就是你们说的总数量,最后提示percent附近语法错误。declare @tcount int
select @tcount =count(0) from table
select 编号,count(0)*100.0/@tcount from table group by 编号