MYSQL: Query the last conversion on chat messages and sort by latest message

I am having issue on query sorting of last convo messages of each users. Here is my current record on my 2 tables:

enter image description here

enter image description here

I want to achieve below result:

enter image description here

My current query is:

 SELECT `messages`.*, `users`.`username`, `u2`.`username` as `to_username`,  CASE WHEN to_user_id = 1     THEN `users`.`username`     ELSE u2.username  END as participant  FROM `messages`   LEFT JOIN `users` ON `messages`.`from_user_id`=`users`.`id`   LEFT JOIN `users` as `u2` ON `messages`.`to_user_id`=`u2`.`id`   INNER JOIN (SELECT max(id) as lastmsgId FROM messages where to_user_id = 1 or from_user_id =1 GROUP BY to_user_id) m2 ON `messages`.`id`=`m2`.`lastmsgId`   GROUP BY participant    ORDER BY `messages`.`created_at` DESC 

And the result of my query is: enter image description here

The 4th and 5th message is not sorted properly I am expecting to display the 4th message instead of 5th message. It displays the older message instead of latest one. I couldn’t find the solution on how will be display the right sorting.

Any help and suggestion is very much appreciated.

How do I give the right amount of treasure without going overboard, like my last DM did?

I am trying to find a good model for how much treasure and money to give my players in order not to make items too difficult to buy, or too cheap to buy.

In my last game, which ran for 6 months, our DM ended up so freely giving us gold that everything was trivial for us. Our characters at level 6 were so rich, we could afford any comfort and travel as kings. This was not because we found a treasure hoard, but because our DM had accidentally been giving us too much treasure for our encounters.

For example, every time we would fight something, they would reward us with 1-2 Platinum, sometimes more. They also used in-game currency for out of game creativity. If you made them laugh, you got another Platinum or like 100 Gold.

Nearing the end of the campaign, everything was so cheap that it wasn’t fun anymore to even buy anything or save up for fancy lodgings. We could afford hundreds of potions, countless trips to the local temple, resurrections…etc. There was no threat of dying, no challenge in earning, and the game lost steam fast.

I am not good with math. I am nowhere near an economist, but when I run my campaign I don’t want to end up with the same problem.

Are there any charts or rules of thumb for making a balanced, long-term economy in D&D 5th?

How do I assign treasure in a way that doesn’t inflate to worthlessness down the line?

I am looking for charts, guides or tables ideally. I would really appreciate the help.

Do Abjure Enemy effects last only one turn?

I play the Oath of Vengeance paladin and have came across a problem.

There is the Channel Divinity: Abjure Enemy description, which states:

As an action, you present your holy symbol and speak a prayer of denunciation, using your Channel Divinity. Choose one creature within 60 feet of you that you can see. That creature must make a Wisdom saving throw, unless it is immune to being frightened. Fiends and undead have disadvantage on this saving throw.

On a failed save, the creature is frightened for 1 minute or until it takes any damage. While frightened, the creature’s speed is 0, and it can’t benefit from any bonus to its speed.

On a successful save, the creature’s speed is halved for 1 minute or until the creature takes any damage.

It sounds pretty good, but does anything forbid an abjured enemy from simply harming himself on his turn?

Tiered campaigns showing as broken after last update

Not sure if i am the only one having this issue but I updated my GSA today and when it started back up it is showing that all of my T3 campaigns are broken and they are crossed out.  When I open the campaigns it shows that everything is fine and as it should be, the tickbox to build links to verified links from tier 2 is checked and the campaigns are selected so there is no reason it should be showing as broken. 

after the last two updates my gsa ser loads my vps CPU at 100%

I’ve been running gsa ser on my vps for last couple days with no problem until today. after I update the software twice as recommended. GSA SER has slow down dramatically and my cpu usage has gone thru the roof. GSA gotta get this fix man,NOT GOOD FOR BUSINESS. I dont have the extra money to dish out more memory and ram in my vps service.