Thanks for the reply. I'm happy that others are also tackling the problem of a better query language. My approach isn't actually a full-on Lisp with parentheses and all, rather it's based on a single compound data structure (like Lisp's cons cell, but more like Lua tables). I call it an "arg-tuple", and it's basically a function's arguments in Python, but as a data type (which allows nesting). Add in a simple function call syntax, infix operartors and a "pipeline" operator (like F#'s |>) and you get something like this:
from stops
| let region :be case(zoneid,
:when ("P", "0", "B") :then "Prague",
:when ("1", "2") :then "Almost-Prague",
:else "Regional")
| where lat != 0 && lon != 0 && region != "Prague"
| select name, region
"from", "let", "where" and "select" are filters, functions that take a query description object and return a new one. "name, region" is just an arg-tuple with two unnamed elements and "case" is a function taking one polymorphic value and a variable number of nested arg-tuples with ":when: and ":then" named elements.
Filters can be arranged in any order, unlike SQL, so this would work:
from stops
| group_by lat, lon
| group_by lat
| select min(group.lon)