Fix miscoded SQL