Ah, now I see what you mean by using a macro -- that's rather ugly. You could just build the query s-expression with a simple function, and feed it to sql-compile instead... or just use :raw, as you showed. Cheers, Marijn