I have a table with columns PredCustId, StartDT and EndDT. For a given StartDT, there can be multiple PredCustIds. Here's what this looks like
For each unique StartDT, I would like to retrieve the row with the largest PredCustId. I am specifically trying to implement the left-join solution as seen here but the query hangs every time I run it and I don't understand why.
This works
SELECT a.*
FROM PredCusts AS a
LEFT OUTER JOIN PredCusts AS b
ON a.StartDT = b.StartDT;
but this hangs
SELECT a.*
FROM PredCusts AS a
LEFT OUTER JOIN PredCusts AS b
ON a.StartDT = b.StartDT AND a.PredCustsId < b.PredCustsId;
Why? Note that I am using MySQL 5.7.21 and MySQL Workbench 6.3.
EDIT My table has ~370,000 rows. The only index is the Primary Key, PredCustsId.