From: Jan Steinman Date: October 6 2012 2:18pm Subject: RE: Accessing Column Aliases In Other Columns? List-Archive: http://lists.mysql.com/mysql/228345 Message-Id: MIME-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Thanks, Rick! I had forgotten all about variables for some strange reason... The subselect isn't nearly as nice as variable, because I'd have to = repeat it several times. On 5 Oct 12, at 20:19, mysql-digest-help@stripped wrote: > From: Rick James >=20 > One way: >=20 > SELECT @foo :=3D this + that, > more_stuff + @foo > FROM ...; >=20 > Another way: >=20 > SELECT foo, > more_stuff + foo > FROM ( > SELECT this + that AS foo > FROM ... ) x; >=20 >> -----Original Message----- >> From: Jan Steinman [mailto:Jan@stripped] >>=20 >> I would like to refer to calculated columns in other columns. I = thought >> a column alias would do it, but apparently they're only for >> aggregation, like GROUP BY. >>=20 >> Other than repeating the entire calculation, what techniques are >> available for accessing such a calculation? >>=20 >> I'm calculating an electric bill, based on meter readings. I need to >> subtract two meter readings, and use that number in several other >> calculations, for example. >>=20 ---------------- :::: I see rejection in my skin, worry in my cancers, bitterness and = hate in my aching joints. I failed to take care of my mind, and so my = body now goes to hospital. -- Astrid Alauda :::: Jan Steinman, EcoReality Co-op ::::