Today I overheard a couple coworkers on an unrelated business area talking about a SQL query they were using for two years that turns out is not quite correct. They were talking about what specific aspects of the query needed to be fixed in order to get the correct result.

Let's say someone at your company relies on some metric or KPI to make a business decision. If you were the one that got assigned how to get that metric, or are the one that has been used such method for a while, how should you proceed moving forwards?

Obviously fixing it and improving the KPI or metric would be key, but I am more interested in how to report it in order to not get fired (should you be fired for this type of thing? I honestly do not know), or how to avoid this having implications in future salary adjustments or promotions, if it can be avoided.

Would it be assumed as a cost of doing somewhat complex business or could it be interpreted as a sign of incompetence? For context I (and my coworkers) work in areas where it is not unusual to program dozens/hundreds of different querys, some ad hoc, some with more thought put behind, in order to satisfy other areas of the business needs.

  • 1
    One of the key things to do will likely be to process some meaningful chunk of data both the old way and the proposed new way, and be able to walk into whatever decision making meeting ultimately results with comparisons and an explanation of the causes of the difference. Aug 22, 2019 at 13:22
  • I like this comment a lot, I should have think about this. Always best to go with an solution to a problem, this is a really good answer! Aug 26, 2019 at 6:20
  • You might also want to add suggestions for safety measures, e.g. tests to run on a metric to make sure that such an error doesn't happen anymore.
    – Dirk
    Aug 28, 2019 at 14:30

2 Answers 2


Short answer: Yes. Raise it with your manager, they can then determine how to proceed and with whom.

Firstly, if you were to get fired for reporting something that someone else already knows about that has been around for two years, then you probably have bigger issues to worry about in that organisation.

Now that's out of the way, I would suggest you speak with your direct manager about it. Did you write this query, yourself? Or was it something produced in your team.

The other thing is that if it's been around for that long and nobody's picked it up, then the results they're getting are either answering business questions in a way that is useful, or they simply aren't relying on the results of it because they know it's wrong.

Either way, you really should speak with your manager so they can liaise with the appropriate people about how to proceed. You might just find that the business people are grateful that someone finally flagged it as a problem.

  • 1
    Honestly I never thought about it from the angle of "they are not relying on the results because they know". That's a very interesting perspective. I assumed they would use it and accept it as truth. Another thing, maybe I expressed myself poorly but I meant to say that nobody reported the query as wrong. This people just realized and are working on fixing, and that got me thinking what would I do if it were me Aug 22, 2019 at 6:54
  • 1
    This is a nice answer. I work in a company where something goes wrong on a pretty regular basis, not because we're so bad at it, but because there is so much going on in the first place. And basically the only thing that ever got anybody fired was lack of transparency (at least if we're talking about a first offence). Aug 22, 2019 at 10:47

Before fixing the problem this should be discussed with a manager or the (key-)users of these numbers, depending on the business.

Fixing the problem without informing the people that use those numbers might have a negative impact on the business.

Either it will be seen as a bug even though it technically was a bug until now. But the users just see "something has changed and it's not how it used to be" and without an explanation they perceive it as wrong.

Or the users will think, for example: "production is getting worse", even though it is the same as before just the interpretation or calculation of the numbers changed and nobody knows.

  • That's another great perspective I did not think about, it being perceived to get worse, or way too different and no longer useful. Aug 22, 2019 at 8:09
  • This is a really good point. You don't want to silently fix things without considering the implications. It may be the case that the trigger levels or targets (or whatever) for this KPI needs an adjustment to reflect the different calculation method. It sounds like the OP is involved in retrieving data for KPIs on a regular basis, it probably makes sense to have a departmental policy on how to address bugs in queries that are discovered on in-use measurements, if one doesn't already exist.
    – dwizum
    Aug 22, 2019 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .