If I understood your logic correctly, you are trying to sum the doc_id for a particular app_id. There may be more than one doc_id for same app_id, but you want to count only one of them. If you have to do this, I can't think of any other way.
Unique and Distinct are same.