At 9:19 PM +0100 2000-01-05, Gregor Welters wrote:
>At 16:52 05.01.2000 , Paul DuBois wrote:
>>>Hi!
>>>
>>>I have a table which is updated almost every day. There is a Field
>>>with a date - but it's varchar.
>>>Now I want to get the newest 100 rows.
>>>
>>>Can someone show me the way how to do this?
>>
>>
>>If you've entered the values in a consistent format, then they should
>>sort in date order. You can use ORDER BY col_name DESC on that column
>>and LIMIT 100 to pick the first 100 rows of the result.
>
>great, I didn't expect such a simple solution!
>
>now, let me extend the question a bit:
>
>I wan't to know the range of values (minimum and maximum) in a
>numeric column in this 100 rows,
>and I wan't it in the same query...how can I do that? (I played
>with the min() and max()-functions - but it didn't work)
MIN() and MAX() are applied before LIMIT is evaluated. What you could
do is retrieve the 100 rows into a temporary table, then use MIN() and
MAX() on the contents of the temporary table.
--
Paul DuBois, paul@stripped