Show us the code you are using to execute this query.
Just because a query can be executed through the Site Admin web interface doesn't mean it can be executed programmatically using the OTA API.
Assuming you are using the Command object from the OTA API, is the user making the connection through the API a member of the TDAdmin group for the project? If not, have you set the DISABLE_COMMAND_INTERFACE Site Configuraiton parameter appropriately to let members of other groups use the Command object? You can learn more about that parameter in the Administrator Guide.
Just because a query can be executed through the Site Admin web interface doesn't mean it can be executed programmatically using the OTA API.
Assuming you are using the Command object from the OTA API, is the user making the connection through the API a member of the TDAdmin group for the project? If not, have you set the DISABLE_COMMAND_INTERFACE Site Configuraiton parameter appropriately to let members of other groups use the Command object? You can learn more about that parameter in the Administrator Guide.