Basically u better buy a car which is still under warranty & before buying u need to check the electrical parts (which u can inspect by ur self) e.g. 4 windows, sunroof (if applicable), the rear AC, electric seats (move in all possible directions) after u satisfy ur self about the above (& reduce the price for anything which is not working) check the history of the car in the main dealer (coz recently we started hearing some showrooms playing in the mileage clock & reducing it outside qatar & coming back to sell the car for an expensive price)
then u can take it either to main dealer or to any inspection center (German experts "salwa road" or car Max "airport street" are recommended) to inspect the mechanical status and engine should get more than 92% otherwise try to avoid, another important issue is the chassis which should not have any accident (or bend) otherwise the price should reduce by Min. 40%.
Finally make sure about the availability of the spare key and user's manual.
Good luck