You are performing a UNION between two tables, and in the first half of the union you have the sum of integers for the diff column while in the second half you have a string. In general, it is required that the types of all the columns are in agreement. One way around this would be to cast your timestamp difference term as char, i.e.