TPCH Q5 implementation