1. A programmable apparatus for building query statements, comprising a processor; a memory; a query schema in the memory, the query schema describing one or more query entities; a select macro in the memory; and a macro expansion program in the memory directing the processor to separate the select macro into a plurality of macro tokens; compare each macro token with each query entity; and responsive to matching a macro token with a query entity, expand the matched macro token according to the query schema.