Umar Waliyullah
Umar Waliyullah

Reputation: 529

List records that have multiple collaborators

I want to list all the records that have more than one different collaborators ("added_by") as per table below:

Table: report

The result expected are report_id having values 103, 104.

report_id having value 102 has been excluded because the entries have been added twice by the same user.

Upvotes: 0

Views: 35

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522311

One way to translate your requirements is to aggregate your table by report and retain those reports having more than one distinct contributor.

SELECT 
    report_id
FROM yourTable
GROUP BY
    report_id
HAVING COUNT(DISTINCT added_by) > 1

Upvotes: 2

Related Questions