Specific query for custom post type

For most popular you can use something like https://github.com/williamsba/WordPress-Popular-Posts-with-Custom-Post-Type-Support/blob/master/wordpress-popular-posts.php

Actually there are several plugin and solutions it you check google, did you try it?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)