generates standard SQL for DW