SELECT EMPLOYEE.MEMP , EMPLOYEE.MPNAME + CHAR(9) + EMPLOYEE.MFNAME + CHAR(9) AS NAME , EMPLOYEE.MFLASTNAME, Min(Interest.MINTEREST)
FROM Interest INNER JOIN EMPLOYEE ON EMPLOYEE.MEMP = Interest.MEMP
INNER JOIN EMPLOYEEDT ON EMPLOYEE.MEMP = EMPLOYEEDT.MEMP
WHERE Interest.YEAR = '2557'
Group by EMPLOYEE.MEMP , EMPLOYEE.MPNAME + CHAR(9) + EMPLOYEE.MFNAME + CHAR(9) AS NAME , EMPLOYEE.MFLASTNAME
ORDER BY EMPLOYEE.MEMP ;
หรือใช้ subselect min Code (SQL)
SELECT EMPLOYEE.MEMP , EMPLOYEE.MPNAME + CHAR(9) + EMPLOYEE.MFNAME + CHAR(9) AS NAME , EMPLOYEE.MFLASTNAME, (Select Min(Interest.MINTEREST) From Interest Where EMPLOYEE.MEMP = Interest.MEMP) MINTEREST
FROM EMPLOYEE INNER JOIN EMPLOYEEDT ON EMPLOYEE.MEMP = EMPLOYEEDT.MEMP
WHERE Interest.YEAR = '2557'
ORDER BY EMPLOYEE.MEMP ;