I want to order my data by the date of the first occurrence of ID, then by the Started column. How can I do this?
Sample data:
ID Started Result
BcdMhdQf5L|2023-02-06 14:13:45.697587|ONLINE
BcdMhdQf5L|2023-02-06 14:35:56.836783|NETWORK
VbR7aK4ENK|2023-02-03 13:08:10.601581|ONLINE
VbR7aK4ENK|2023-02-03 13:08:10.619467|ONLINE
VbR7aK4ENK|2023-02-03 13:08:25.252219|NETWORK
VbR7aK4ENK|2023-02-03 13:08:38.480098|ONLINE
VbR7aK4ENK|2023-02-06 10:21:39.077173|ONLINE
fpnct7eR5o|2023-02-03 13:09:03.907468|NETWORK
fpnct7eR5o|2023-02-03 13:09:03.932700|ONLINE
fpnct7eR5o|2023-02-03 13:09:18.252934|ONLINE
fpnct7eR5o|2023-02-03 13:13:31.717305|ONLINE
fpnct7eR5o|2023-02-06 10:20:52.256900|ONLINE
Order that I would like the results:
VbR7aK4ENK|2023-02-03 13:08:10.601581|ONLINE <- First because 2023-02-03 13:08:10.601581 is the earliest entry
VbR7aK4ENK|2023-02-03 13:08:10.619467|ONLINE <- The rest are all from ID VbR7aK4ENK, sorted by the date
VbR7aK4ENK|2023-02-03 13:08:25.252219|NETWORK
VbR7aK4ENK|2023-02-03 13:08:38.480098|ONLINE
VbR7aK4ENK|2023-02-06 10:21:39.077173|ONLINE
fpnct7eR5o|2023-02-03 13:09:03.907468|NETWORK <- Second because the date of this ID is next in the sequence
fpnct7eR5o|2023-02-03 13:09:03.932700|ONLINE
fpnct7eR5o|2023-02-03 13:09:18.252934|ONLINE
fpnct7eR5o|2023-02-03 13:13:31.717305|ONLINE
fpnct7eR5o|2023-02-06 10:20:52.256900|ONLINE
BcdMhdQf5L|2023-02-06 14:13:45.697587|ONLINE <- Finally, this ID because it's earliest entry is later than any entry in the other IDs
BcdMhdQf5L|2023-02-06 14:35:56.836783|NETWORK
I've tried several different ways to generate this data, but none of my SQL statements produce what I want. I end up with each ID showing up only once, or the ID's are split up by date, etc.
How can I produce the result that I want?