I am new to Oracle and SQL. As I have started learning on my own with database query programming, I am looking for a tip or solution to my problem:
I created myself a random database with order tickets for different products. In my advancedorders table I have a detailed breakdown of what has been changed at any given time.
Below I present the situation:
I would like to construct the database query so that it searches only for the oldest records from a given group by ID:
And get something like this:
I have tried this query:
SELECT *
FROM database.advancedorders
INNER JOIN (
SELECT
TICKET_ID,
max(id) as maxId
from database.advancedorders
group by TICKET_ID
) groupedTable
ON advancedorders.id = groupedTable.maxId
and advancedorders.TICKET_ID = groupedTable.TICKET_ID
However, I am not getting this query... Can someone please advise me?