Started work on the query formula.

Signed-off-by: firebellys <firebelly@gmail.com>