Show the project id for all documents.
select project_id from documents
For each of them, count the number of documents.
select project_id, count(*) from documents group by project_id
Sort the ids by these counts.
select project_id from documents group by project_id order by count(*)
Which project id has the fewest?
select project_id from documents group by project_id order by count(*) asc limit 1