How to run Custom Query in Magento ?

Check out the below code.