Modified SQL statement to work with latest table
Code modified to work with latest tables in database
SQL statement updated to work with latest tables