tidied some sql #12