calc from query