select * from Result as r where r.turnover=(select max(turnover) from result where mouth=r.mouth " + and year=r.year )order by r.year desc , mouth desc";
上面一个语句是我搜索每个月的某员工 最高销售额的信息现在我想把员工中干部级别的去掉,也就是说只让什么份为业务员的员工参与评比
select * from Result as r where r.turnover=(select max(turnover) from result where mouth=r.mouth and year=r.year and r.AimSort='"+sort+"' and r.seller=any(select name from user as u where u.role='业务员')) order by r.year desc , mouth desc";但是如果有其他人的成绩大于业务员的话 我就搜不到想要的值 这个语句我应该怎么修改 才对 请指教
上面一个语句是我搜索每个月的某员工 最高销售额的信息现在我想把员工中干部级别的去掉,也就是说只让什么份为业务员的员工参与评比
select * from Result as r where r.turnover=(select max(turnover) from result where mouth=r.mouth and year=r.year and r.AimSort='"+sort+"' and r.seller=any(select name from user as u where u.role='业务员')) order by r.year desc , mouth desc";但是如果有其他人的成绩大于业务员的话 我就搜不到想要的值 这个语句我应该怎么修改 才对 请指教
from Result r inner join (
select r1.year,r1.mouth,max(r1.turnover) as maxTurnover
from result r1 inner join user u1 on r1.seller=u1.name
where u1.role='业务员'
group by r1.year,r1.mouth) b
on r.year=b.year and r.mouth=b.mouth and r.turnover=b.maxTurnover
where r.AimSort='"+sort+"'