Skip to content

Conversation

@hussam-it-max
Copy link

No description provided.

@yunchen4 yunchen4 self-assigned this Sep 5, 2025
Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a suggestion for business requirement consideration.

Comment on lines +4 to +8
await client.query(`SELECT RP.paper_title,COUNT(PA.author_id) FROM research_papers RP LEFT JOIN papers_authors PA ON RP.paper_id=PA.paper_id GROUP BY RP.paper_title`);
await client.query(`SELECT COUNT(PA.paper_id) AS total_papers_by_female FROM author A JOIN papers_authors PA ON A.author_id = PA.author_id WHERE A.gender = 'F';`);
await client.query(`SELECT A.university,AVG(A.h_index) AS avg_h_index FROM author A GROUP BY A.university;`);
await client.query(`SELECT A.university,COUNT(PA.paper_id) AS research_papers FROM author A JOIN papers_authors PA ON A.author_id=PA.author_id GROUP BY A.university`);
await client.query(`SELECT A.university,MIN(A.h_index) AS min_h_index,MAX(A.h_index) AS max_h_index FROM author A GROUP BY A.university`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your queries are correct. For query:

SELECT COUNT(PA.paper_id) AS total_papers_by_female FROM author A JOIN papers_authors PA ON A.author_id = PA.author_id WHERE A.gender = 'F';

If a paper has two different female authors, this paper will be counted twice. Depending on the business requirements, this might be what we want. If you don't want to count the same paper twice, you need to use DISTINCT keyword.
Similar thing happens for this query too:

SELECT A.university,COUNT(PA.paper_id) AS research_papers FROM author A JOIN papers_authors PA ON A.author_id=PA.author_id GROUP BY A.university

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants