I am using postgresql to display QA% in my project. Now issue is that, QA% for one of the user is showing wrong data.
this is my calculation I am using to show QA%
(to_char(( (coalesce(s_qa_num,0) + coalesce(s_qa_num_adtl,0))/nullif(coalesce(s_qa_den,0) + coalesce(s_qa_den_adtl,0),0))*100,'999D99')||'%')::character varying as qa_pct
Output from the view I have created
https://pastiebin.com/5db2d1589ef6b
the view I am using for this
https://pastiebin.com/5db2d1cb48822
the query I run in pgadmin
select * from mystats_in_eligbility.vw_m_quality where empl_id = '329509'
AND dte BETWEEN '2019-03-23' AND '2019-09-06'
order by dte desc;
Current result for QA% is 97.53% expected result is 96.34%.
CREATE TABLE blah...
) and data (INSERT INTO blah VALUES...
). And please give us the full SQL statement - context is important! I have a few articles on how to ask questions here on my profile - you might want to take a look? p.s. welcome to the forum! :-)INSERT INTO
) for us to look at to check the validity of the calculation. Furthermore, you have)||'%')::character
but a search of both pastebins for the%
character gives nothing so I'm wondering where it is? Your query is very large and it would appear to be very tricky to zone in on your QA% problem - is there any way you could produce a Minimum, Complete Verifiable Example?