SELECT LeaveDescription AS LT_DESCRIPTION,EMP_FIRSTNAME,EMP_LASTNAME, Openingbal AS LI_OPENING,CurrEncahsed AS ENCASHED, (SELECT Count (DISTINCT LEAVE_FORM_DETAIL.LFD_SLEAVE_FORM) FROM LEAVE_FORM_DETAIL INNER JOIN leave_detail ON LEAVE_FORM_DETAIL.LFD_SEMPLOYEE = leave_detail.ld_semployee WHERE (LEAVE_FORM_DETAIL.LFD_SEMPLOYEE = 'RP00004') AND leave_detail.ld_ileave_year = '2017' and lfd_sleave_type = SETUP_LEAVETYPE.LT_CODE ) AS UTILIZED, IsLWP LWP, UptoEncahsed AS PrevMonEncashed, UptoUtilized AS PrevMonUtilized, 0 AS PrevMonLwp FROM vu_leaveInfo,SETUP_EMPLOYEE ,SETUP_LEAVETYPE where vu_leaveInfo.lm_semployee=SETUP_EMPLOYEE.EMP_CODE And vu_leaveInfo.LeaveType=SETUP_LEAVETYPE.LT_CODE And vu_leaveInfo.Period= 25 AND SETUP_EMPLOYEE.EMP_ID='AFE14526234F2485' --group by Period,LeaveDescription,Openingbal,UptoEncahsed,EMP_FIRSTNAME,EMP_LASTNAME,UptoUtilized,CurrUtilized,IsLWP, UptoEncahsed,CurrEncahsed,LeaveType order by LeaveDescription asc