Added a limit option to the sql query generator