Hi "MySQL",

> I record some stock data into MySQL, I'm looking for the correct
> syntax for a SELECT statement.
>
> SELECT min(Tmin) FROM quotes WHERE low=min(low)
>
> In short, I want the time of the occurance of the low for the day,
> Tmin is time column.  Once the low is achieved, all the remaining data
> for the day has the same low recorded, so I want the first occurance.
>
> I tried
>
> SELECT min(tmin) FROM quotes WHERE tag='CSCO' HAVING min(low);
>
> which at least didn't have syntax errors, but alas did not produce a
> result.

MIN() etc are group functions, so it is difficult to compare them with
(scalar) values from individual rows - hence the failure of the first
attempt.

The second attempt is missing the intended comparison in the HAVING
clause, so the MIN() result is interpreted as boolean and 'this dog
don't hunt, Wilbur!'.

I'm a little confused about the ambiguities of the MIN( tmin ) in the
SELECT clause - perhaps you should post your table schema - if this is
relevant.

Using a test table I happened to have 'lying around', would this
approach fit the bill?

SELECT id, type_id, product_id
  FROM attribute
  WHERE type_id = 2
  HAVING min( product_id ) = product_id;

Regards,
=dn


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to