B轮融资|sql中sum函数跟count函数用法

B轮融资|sql中sum函数跟count函数用法


sql中sum函数跟count函数用法
范例获取产品总数 , 按订单号分组
select tmpordernosum(productnum) as productnum from tmporderdetail where tmporderno in (select tmporderno from [tmporders
where isplay=1) and
productnumiid=123456 and productskuid<>'' and invoice_no<>'' group by tmporderno
范例获取产品总数
select sum(productnum) as productnum from tmporderdetail where tmporderno in (select tmporderno from [tmporders
where isplay=1) and
productnumiid=123456 and productskuid<>'' and invoice_no<>''
//查询送培单位下学员的选修课积分总和
select sum(tp.score) from (select a.StudentIDa.ElectiveIDb.score from Tr_ElectiveStudent a
left join (select ElectiveIDisnull(sum(ElectivePoint)0) as score from Tr_Elective group by ElectiveID) as b
on a.ElectiveID=b.ElectiveID and a.LearnState=1) as tp where tp.StudentID in(select Student_ID from Tr_Student where Unit_ID in(45))
【B轮融资|sql中sum函数跟count函数用法】注意事项:sum函数只对唯一的ID才准确