I'm having trouble selecting all versions, just not the last version in my database using SQL.
This is what my database looks like:
id | titleid | version
----------------------
1 | TEST1 | 1.27
2 | TEST1 | 1.28
3 | TEST1 | 1.29
4 | TEST1 | 1.30
5 | TEST2 | 1.05
6 | TEST2 | 1.06
7 | TEST2 | 1.07
8 | TEST2 | 1.08
I want to SELECT the records 1, 2, 3, 5, 6, 7 since they're not the highest version.
I've tried searching SO but I can't seem to find anyone having the same issue as me.
Does anyone know how I can do this? Appreciate it a lot.
Is this what you want?
select t.*
from t
where t.version < (select max(t2.version) from t t2 where t2.titleid = t.titleid);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With