select datediff(ward_hd,allen_hd)*24 hr,
datediff(ward_hd,allen_hd)*24*60 min,
datediff(ward_hd,allen_hd)*24*60*60 sec
from (
select max(case when ename='WARD'
then hiredate
end) as ward_hd,
max(case when ename='ALLEN'
then hiredate
end ) as allen_hd
from emp
) x;