T0A Posted August 3, 2018 Share Posted August 3, 2018 The Database that I'm using I got it but I don't know how to match them together: return the MAX-n1 & MAX-n2 SELECT MAX(`VID`)-3 AS max1, MAX(`VID`)-2 AS max2 FROM `tests` GROUP BY `SID` return the value of the rows: SELECT * FROM `tests` WHERE `VID`>='max1' AND `VID`<='max2' ORDER BY `SID` ASC, `VID` ASC the results should be like this : Quote Group:1 test - 3 test - 4 Group:2 test - 283 test - 284 Group:3 test - 197 test - 198 Group:4 test - 173 test - 174 Group:5 test - 117 test - 118 Group:6 test - 162 test - 163 Group:7 test - 203 test - 204 Group:8 test - 72 test - 73 Group:9 test - 126 test - 127 Group:10 test - 106 test - 107 Quote Link to comment Share on other sites More sharing options...
requinix Posted August 3, 2018 Share Posted August 3, 2018 So you want all rows that are between max-3 and max-2? Use a JOIN with a subquery. But note that you need to consider the SID values if you're grouping by it. Give that a shot and post what you have if it isn't working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.