Added possibility to reference aliases in SQL query