sql query using alias in where clause