Алёна アりヨナ Raydro
@L
@ Lusi @
1) select c.fil, c.name from client c, oklad o where c.id=o.id and c.fil=o.fil and o.stavka>1100 and month(o.dtdate)=1
2) select c.name, c.fil, avg(o.stavka) from client c, oklad o where c.id=o.id and c.fil=o.fil group by c.id, c.fil, c.name having avg(o.stavka)<1500 order by c.name
3) select fil, name from client where dtstart<='2012.03.01' and (dtend>'2012.03.31' or dtend is NULL)
2 этап:
select fio, oklad, dtdate from (select fio, oklad, dtdate from table t1 left join (select fio nfio, max(oklad) max from table group by fio) t2 on t1.fio=t2.nfio where oklad=max) t
или
select fio, oklad, dtdate from table t where oklad=(select max(oklad) from table where fio=t.fio)
Похожие вопросы