The section shown as the problem was nothing more then an attempt at sorting but causes the entire database to output
with km equaling 0 I probably should have asked the question leaving that part out.
I eliminated thing that have to do with count and other funtions to make it more brief and example.