Search code examples
sqloracle-databasetop-n

How to fetch the first comment date of users in comments table


have a comments table and need to get the first comment date (first inserted record) of each users in the table.

Output will be :

user_id   first_comment_date

Solution

  • You can use min() try

    SELECT user_id, MIN(comment_date) 
    FROM commentstable 
    GROUP BY user_id;