Columsn query rewriting