added gw similarity function for sql