less than 1 minute read

Problem

problem

My Solution

SELECT author_id as id
FROM Views
WHERE author_id = viewer_id
GROUP BY id
ORDER BY id ASC

Editorial Solution

In SQL, we can use the keyword DISTINCT in the SELECT statement to retrieve unique elements from the table Views. We also apply a condition using the WHERE clause. This condition filters out only those rows where the author_id is equal to the viewer_id.

SELECT 
    DISTINCT author_id AS id 
FROM 
    Views 
WHERE 
    author_id = viewer_id 
ORDER BY 
    id 

Tags:

Updated: