Skip to content
Advertisement

Fetch record from table?

I have table in which data is like this

Mapping Relationship

1 task_id is mapped to multiple task_detail_id (1 to Many)

What I want is to traverse the table and fetch record as if same task_id exist more than 2 times then fetch top 2 (latest) records for that task_id

Sample Output

Advertisement

Answer

This is typically done with a window function:

Online example

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement