SELECT *
FROM
( SELECT staff_key , fname || ' ' || lname AS comp_name ,poss
FROM BASE_DATA_STAFF
WHERE key ='791'
GROUP BY staff_key ) AS QR_BASE ,
( SELECT staff_key COUNT(rdate) FROM vw_report_enter
WHERE key ='791'
GROUP BY staff_key ,STATUS
HAVING status = 'สาย' ) AS QR_STATUS
WHERE ( QR_BASE.staff_key =QR_STATUS.staff_key )