select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM from tblemployee group by emid having emstatus = 1 and emid not in (select emid from tblrespon) order by SUM DESC,emid ASC limit 0,5
insert into tblselemp(id_emp,idpro) value('EM0006','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0007','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0008','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0009','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0010','570208/03')
หลุดลูป
select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM from tblemployee group by emid having emstatus = 1 order by SUM DESC,emid ASC limit 0,3
insert into tblselemp(id_emp,idpro) value('EM0010','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0010','570208/03')
insert into tblselemp(id_emp,idpro) value('EM0010','570208/03')
1)
select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM from tblemployee group by emid having emstatus = 1 and emid not in (select emid from tblrespon) order by SUM DESC,emid ASC limit 0,5
2)
select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM from tblemployee group by emid having emstatus = 1 order by SUM DESC,emid ASC limit 0,3