Hi Dan:
Not very sure, but you could try exploring "user variables":
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html
Regards,
Alvaro Cobo
Dan Jakubiec escribió:
> Hi Chris,
>
> On 9/10/06, Chris W <2wsxdr5@stripped> wrote:
>>
>> This works on a table I have.
>>
>> SELECT MIN(tone) as `min`, MAX(tone) as `max`, MIN(tone)/MAX(tone) as
>> ratio FROM pltone p
>>
>>
> Thanks for the suggestion. This works for me too, but what I'm really
> looking for is a way to *alias* the first two columns. The calculations I
> am doing are more complicated than just "MIN()" or "MAX()". Conceptually,
> I'd like to generate two columns which contain the result of complex
> equations, and then a third column which combines the first two using
> another complex equation. In other words, I don't want to repeat the
> formulas/computations from columns 1 and 2.
>
> Using your example, I'd like to do something like:
>
> SELECT MIN(tone) AS min, MAX(tone) AS max, min/max AS ratio FROM pltone p;
>
> But when I do that, I get the following error from MySQL: "ERROR 1054
> (42S22): Unknown column 'min' in 'field list'". So I'm wondering if there
> is another way to alias the first two columns, or if this simply isn't
> permitted in SQL. Any ideas? Or is the only way to do this via a
> sub-SELECT?
>
> Thanks,
>
> -- Dan
>