I have an issue with a very complex query. The database is Informix but don’t worry about that.
This query is the result of a prepared procedure which needs 8 tables to get to this point.
This is just a small extract of the result, the problematic part.ñ
sessionid startdatetime enddatetime talk ring queue 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 0 17 30000034352 11/12/2014 8:34 11/12/2014 8:34 0 1 17
As you can see all the rows are exactly the same except for the last one which has a ringtime of 1 sec. In this particular case. You would think that adding a condition of ringtime > 0 or using a MAX(ringtime) would do the trick and I would get rid of all those rows which worth nothing for me.
My problem is that I can’t do that because there are some records where the ringtime is 0 but it should be counted.
So with a DISTINCT I can, at least, reduce the problem… but I can’t get rid of it… Any ideas?