Subject RE: [firebird-support] Strange FIRST n SKIP m + Function behaviour in FB 2.5 Beta 2
Author Kim Sandell (Celarius)
Thanx,



the reason I was trying to use the statements was to calculate the Median of
a data-range.



I've now solved it as:



/* For Even count of values (Data range count is 20000 values)*/

SELECT FIRST 1 SKIP 10000 DUR_TOTAL AS Median FROM HTTP_Events ORDER BY
DUR_TOTAL



/* For UnEven count of values (Data range count is 20001 values)*/

SELECT AVG(DUR_TOTAL) AS Median FROM

(SELECT FIRST 2 SKIP 10000 DUR_TOTAL FROM HTTP_Events ORDER BY DUR_TOTAL)



-Kim







From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Alan McDonald
Sent: 23. syyskuuta 2009 00:18
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Strange FIRST n SKIP m + Function behaviour
in FB 2.5 Beta 2

> Hi,
>
> I've got a few SQL Queries that behave strangely with FB v2.5 Beta 2:
>
> 1st the OK situations:
>
> SELECT FIRST 3 Dur_Total FROM HTTP_Events
> gives 3 result rows: 0.5575, 1.2298, 0.7567
>
> SELECT FIRST 2 SKIP 1 Dur_Total FROM HTTP_Events
> gives 2 result rows: 1.2298, 0.7567
>
> Now the problem statements:
>
> SELECT FIRST 2 SKIP 1 Min(Dur_Total) FROM HTTP_Events
> gives 0 result rows????? Correct answer would be 1 row with value
> 0.7567
> The same happens with MIN(), MAX(), AVG(), SUM() etc...
> Event COUNT() gives an empty result...

but the first one is going to be your min and you skip it...
don't use first and skip with aggregate selects.

Alan





[Non-text portions of this message have been removed]