User Profile
AmyMagz
Copper Contributor
Joined Nov 10, 2023
User Widgets
Recent Discussions
SQL - percentage using data from case statement
Is there a way of calculating a percentage based on the information returned from a case statement within the SQL? I currently have the below case statement, and then a separate static spreadsheet to calculate the percentage of KPI 'pass'. Has anyone got examples of SQL that calculate that automatically? Thanks in advance (case statement below) case when a.job_type_code = 'CL04' and a.actual_comp_date <= b.target_time and a.Photo_Pass = 'Pass' then 'Pass' when a.job_type_code = 'CL04' and a.actual_comp_date <= (b.target_time + 0.006944444444444) and a.Photo_Pass = 'Pass' then 'Pass' when a.job_type_code = 'CL04' and a.actual_comp_date is null and sysdate <= (b.target_time + 0.006944444444444) then 'Job open - time remaining' when a.job_type_code = 'CL04' and a.actual_comp_date is null and sysdate <= (b.target_time + 0.006944444444444) then 'Job open - OVERDUE' -- All other jobs need to base this on whether they COMPLETED before the target time when a.job_type_code != 'CL04' and a.actual_on_site <= (b.target_time + 0.006944444444444) and a.Photo_Pass = 'Pass' then 'Pass' when a.job_type_code != 'CL04' and a.actual_comp_date is null and sysdate <= (b.target_time + 0.006944444444444) then 'Job open - time remaining' when a.job_type_code != 'CL04' and a.actual_comp_date is null and sysdate <= (b.target_time + 0.006944444444444) then 'Job open - OVERDUE' when a.job_type_code != 'CL04' and a.actual_on_site <= b.target_time and a.Photo_Pass = 'Pass' then 'Pass' else 'Fail' end as KPI_Check,601Views0likes0Comments
Recent Blog Articles
No content to show