hi Eyal, that does tell you the minimum distance, but not the month which is the minimum distance, i believe?  so if your month is july, you might know the nearest month is august or june, but not which one.

On Fri, Jul 17, 2015 at 10:39 AM, Eyal Rozenberg <eyalroz@technion.ac.il> wrote:

This is probably more of a question than an answer, but - why wouldn't
this work?:

CREATE TABLE nearest_matches AS
    ( SELECT a.* ,
        (
            SELECT min(abs(z.svcmon - a.svcmon))
            FROM person_table AS z
            WHERE a.yr = z.yr AND a.person_id = z.person_id
        ) AS nearest_month
    FROM event_table AS a ) WITH DATA


(... that is, aggregation instead of TOP 1.)

Eyal


On 04/06/2015 14:39, Anthony Damico wrote:
> https://stackoverflow.com/questions/30641876/monetdb-sql-method-to-locate-or-match-by-the-nearest-value-without-a-top-or-lim
>
> i'm thinking i can do this with some costly self-join, but i'd
> appreciate any other eyes on the problem
>
>
> _______________________________________________
> users-list mailing list
> users-list@monetdb.org
> https://www.monetdb.org/mailman/listinfo/users-list
>

_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list