SQL query updates

Replaced CDC with SQL queries