Subject | Re: [ib-support] First function |
---|---|
Author | Svein Erling Tysvær |
Post date | 2001-07-17T12:33:21Z |
Hi Robert.
don't use UDFs so others will have to answer that.
given GroupF - but it might be slow:
SELECT GroupF, String FROM table t1
where priority = (select max(priority) from table t2 where t1.groupf =
t2.groupf)
HTH,
Set
>Is there a way to pick the first record in a GROUP BY, like the FirstNo, unfortunately not. Maybe there is a UDF that can do it, but I generally
>function in access?
don't use UDFs so others will have to answer that.
>I have, in effect a table:Well, the following should work if there's no duplicates in priority for a
>
>id | GroupF | String | Priority
>---------------------------------
> 1 | 1 | Hello | 10
> 2 | 1 | Hi | 8
> 3 | 2 | Bye | 9
> 4 | 2 | Goodbye | 12
>
>I want to pick the strings with the highest priority in each group,
>i.e.
>
>GroupF | String
>-----------------
> 1 | Hello
> 2 | Goodbye
>
>I tried:
>SELECT GroupF, Min(String) FROM table GROUP BY GroupF
> HAVING Priority = Max(Priority);
>
>and it didn't give an error, which was a surprise, but it didn't work
>either.
>
>In Access, I thought I could do:
>SELECT GroupF, First(String) FROM table ORDER BY Priority DESC
> GROUP BY GroupF;
>
>but actually, on trying it out, it seems I can't do that, either.
>
>Any ideas?
given GroupF - but it might be slow:
SELECT GroupF, String FROM table t1
where priority = (select max(priority) from table t2 where t1.groupf =
t2.groupf)
HTH,
Set