i am trying to replicate this question in monetdb, which i don't believe supports the TOP command and can only use LIMIT on the outermost result.
if i could use TOP
then i believe this command would give me what i want. is there a reasonable alternative that's not massively inefficient? i need to run this on a table that will quickly max out my server's ram. thanks!
CREATE TABLE nearest_matches AS
( SELECT a.* ,
(
SELECT TOP 1 svcmon
FROM person_table AS z
WHERE a.yr = z.yr AND a.person_id = z.person_id
ORDER BY abs( z.svcmon - a.svcmon )
) AS nearest_month
FROM event_table AS a ) WITH DATA