As far as I know powerdns does not support custom SQL queries. There is already a plugin for powerdns made by falko which will be integrated in 3.0.2. As far as I know he has not published it yet. I will ask him to upload the code to svn.