Show all document ids, names and the number of paragraphs in each document.
create table documents (document_name varchar, document_id varchar, PRIMARY KEY (document_name)); create table paragraphs (document_id varchar, PRIMARY KEY (document_id))
select t1.document_id, t2.document_name, count(*) from paragraphs as t1 join documents as t2 on t1.document_id = t2.document_id group by t1.document_id