revise the sql