Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rank Papers by Discipline

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Rank Papers by Discipline. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Elsevier uses discipline-level citation analytics to compare papers indexed in Scopus. Write a PostgreSQL query that counts citations for each paper and ranks papers within their academic discipline.

Requirements

  1. Include every article associated with a valid discipline, including articles with zero citations.
  2. Calculate each article's citation count from the citations table.
  3. Return both RANK() and DENSE_RANK() rankings within each discipline, ordered by citation count descending.
  4. Sort the final output by discipline name, citation count descending, and article ID.

Representative Sample Data

articles: 101, “RNA Folding in Cells”, Biology; 102, “Plant Genome Networks”, Biology; 107, “Graph Neural Models”, Computer Science; 108, “Efficient Vector Search”, Computer Science.

citations: three rows for article 101, two rows for article 102, and one row each for articles 107 and 108.

Schema

disciplines
ColumnTypeDescription
discipline_idPKINTEGERUnique identifier for an academic discipline
discipline_nameVARCHAR(100)Name of the academic discipline
articles
ColumnTypeDescription
article_idPKINTEGERUnique identifier for a scientific article
titleVARCHAR(200)Title of the scientific article
discipline_idINTEGERReferences the article's academic discipline
citations
ColumnTypeDescription
citation_idPKINTEGERUnique identifier for a citation record
article_idINTEGERIdentifier of the cited article
Tablesdisciplinesarticlescitations
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results