-MySQL Group By MAX Limitation & Workaround (Get Row ID with Max Value)
-Fix: Selecting Row ID with MAX Value in MySQL Group By
-Stuck with MAX in MySQL Group By? Here's the Fix!
-MySQL Got You Down? Master Group By MAX with This Workaround
-MySQL Group By MAX Row ID Issue & Solution (Subquery Concat)
-Fix: Cannot Select Row ID with MAX in MySQL Group By
-MySQL: Get Whole Row Despite Group By & MAX Limitation (Subquery Workaround)
-MySQL: Group By & MAX Issue? Get All Columns with This Workaround
-MySQL: How to Select Entire Row with MAX in Group By (Subquery Method)
-------------------------------
Code Link :-
https://unpossiblepog.blogspot.com/20...
Subscribe my Channel:-
http://www.youtube.com/user/SanketRoo...
Gaming Channel:-
/ @unpoggaming9532
Gaming Instagram:- (@unpog.gaming)
/ unpog.gaming
Facebook Page:-
/ unpossiblens
Twitter Account:-
/ unpossiblepog
Blog:-
https://unpossiblepog.blogspot.com/
Website:-
https://unpossiblepog.com/
========================
Code :
========================
Hey guys, there is a limitation in MYSQL, where you use group by and wanted max value, but when you try to fetch a row ID or any other column, it fails.
For example, there is one table on the left side called “potential_customers”, and on the right side, I wrote one query which returns maximum NEXT_CALL value for each customer_id.
So, in current example I wanted row ID 2 & 6.
But if I need ID or whole row, it fails even when you use order by column_name DESC.
Thankfully there is a workaround for this which is to use the combination of subquery and concat.
First, let’s alter the query, to concat customer_id and max of next call. Remove all order by if there is any.
Put that query is sub-query by adding rounded brackets around it.
Now, write a select query before sub query, & in where condition, use concat of required column. Don’t forget to use “IN” keyword.
And as you can see, it returns row ID that we need.
You can call whole column if you want.
So that’s it. Code link is given in the description.
Thanks for watching. Like, Share and Subscribe.