sql query to convert to DSU implemented but not working