Removed extra semicolon in the sql command
Changes in SQL formatting
Formatting of code
Added speed optimalization of SQL count select