Compose sql queries for dash and zdash formats.