6/25/2011

MSQL ค้นหาพนักงานที่ไม่เคยกู้เงินบริษัท

ไม่เคยกู้สั้น
 
SELECT EmpID,EmpName FROM sci._employees
WHERE EmpID NOT IN (SELECT EmpID FROM sci_loan.er_history)
AND EmpID NOT IN (SELECT EmpID FROM sci_loan.er_borrow)
AND isenabled = "Y"
ORDER BY LevelPriority DESC,EmpID 
 
 
ไม่เคยกู้ยาว

SELECT EmpID,EmpName FROM sci._employees
WHERE EmpID NOT IN (SELECT EmpID FROM sci_loan.long_history)
AND EmpID NOT IN (SELECT EmpID FROM sci_loan.long_borrow)
AND isenabled = "Y"
ORDER BY LevelPriority DESC,EmpID

No comments:

Post a Comment