column-alias

How can I factor out repeated expressions in an SQL Query? Column aliases don't seem to be the ticket...

So, I've got a query that looks something like this: SELECT id, DATE_FORMAT(CONVERT_TZ(callTime,'+0:00','-7:00'),'%b %d %Y') as callDate, DATE_FORMAT(CONVERT_TZ(callTime,'+0:00','-7:00'),'%H:%i') as callTimeOfDay, SEC_TO_TIME(callLength) as callLength FROM cs_calldata WHERE customerCode='999999-abc-blahblahblah' AND ...

sql alias field

in SQL, supposes I need to refer to an aliased field in the having clause but the alias has quotes, how do I do that? select (select...) as '005' group by ... having '005'>0 ...

[MySQL] Column alias not recognized in WHERE-statement

Hi all, I have a strange 'problem' with one of my created queries. Given the next query: SELECT ID, DistanceFromUtrecht, ( SELECT (MAX(DateUntil) - (ReleaseDays * 60 * 60 * 24)) FROM PricePeriod WHERE PricePeriod.FK_Accommodation = Accommodation.ID ) AS LatestBookableTimestamp FROM Accommodation WHERE LatestBooka...

Oracle rename columns from select automatically?

I have 2 tables with the following fields. Table1 AA BB CC DD Table2 AA CC EE Query Select t1.*, t2.* from table1 t1, join table2 t2 on table1.DD = table2.EE My data columns back with the following column names: AA, BB, CC, DD, **AA_1**, **CC_1**, EE I don't want the column names like that. I want them to have ...