Query to find the second highest row in a subquery

The goal is to send notifications about the customer updates but only for the first one if there are consecutive updates from the customer in a ticketing system.

This is the simplified query that I’m using to get the data that I need. There are a few more columns in the original query and this subquery for threads is kind of required so I can also identify if this is a new ticket or if existing one was updated (in case of update, the role for the latest threads will be a customer):

SELECT t.ref, m.role    FROM tickets t    LEFT JOIN threads th ON (t.id = th.ticket_id)    LEFT JOIN members m ON (th.member_id = m.id)   WHERE th.id IN ( SELECT MAX(id)                      FROM threads                     WHERE ticket_id = t.id                 ) 

It will return a list of tickets so the app can send notifications based on that:

+------------+----------+ | ref        | role     | +------------+----------+ | 210117-001 | customer | | 210117-002 | staff    | +------------+----------+ 

Now, I want to send only a single notification if there a multiply consecutive updates from the customer.


How I can pull last and also one before last row to identify if this is consecutive reply from the customer?

I was thinking about GROUP_CONCAT and then parse the output in the app but tickets can have many threads so that’s not optimal and there are also a few more fields in the query so it will violate the ONLY_FULL_GROUP_BY SQL mode.

db<>fiddle here

non linear second order pde

I try to solve the following problem with zero luck. Any suggestions?

d = 5*10^27; t0 = 0; t1 = 10^7; t2 = 2*10^7; Q = 1;` 

pde = -dD[n[r, t], {r, 2}] – (2d)/rD[n[r, t], r] + D[n[r, t], t] – QDiracDelta[t – t0] – Q*DiracDelta[t – t1]==0`

ic = {n[r, 0] == 1/r, n[0, t] == t^-1.5}

sol[r_, t_] == DSolveValue[{pde, ic}, n[r, t], {r, t}]

Full line trajectories plot for the solution of Second Order nonlinear coupled differential equations

I wanted to plot a phase plane containing the trajectories of the solutions found by using ‘NDSolve’ using the initial conditions for x[0], y[0], x'[0] and y'[0]. The equations are: x”[t] – 2 y'[t] == -x[t] + y[t]^2; y”[t] + 2 x'[t] == x[t] + y[t] + x[t]*y[t]

The equilibrium point for the system is (0,0). I have plotted the stream plot for the system but unable to plot a phase portrait that would give me the full line trajectories of the system for different initial conditions. I am also looking for any periodic solution if present in it. The stream plot I got is given below and I would take initial conditions from it.

enter image description here

I get this by using the Parametric Plot of the NDSolve solution:

enter image description here

Kindly help in this capacity. Thanks in advance.

Does the Psi Warrior’s Psionic Strike ability prompt a second Concentration save?

The new Psi Warrior Fighter subclass has the feature Psionic Power which has the following option:

Psionic Strike. You can propel your weapons with psionic force. Once on each of your turns, immediately after you hit a target within 30 feet of you with an attack and deal damage to it with a weapon, you can expend one Psionic Energy die, rolling it and dealing force damage to the target equal to the number rolled plus your Intelligence modifier.

Based on my earlier question it seems the consensus is that Psionic Strike does not double if the triggering attack is a critical hit.

If Psionic Strike is used on a creature concentrating on a spell does the additional damage prompt a second Constitution save to maintain concentration?

WHY is Soulknife’s second attack NOT Two-Weapon Fighting?

Ask about Soulknife rogue, D&D 5E

Hello, I know there is a question "Do you add your ability modifier to damage for the Soulknife’s second attack?" with reply being "Yes you do because it is not two weapons fighting". This is not IF, but WHY.

Recently I encountered this problem while playing Soulknife and pretty much my entire group was like "it’s in off-hand, it’s two weapons fighting because you are literlly using two blades, it should not apply".

Why wouldn’t Soulknife’s second blade be considered Two-Weapon Fighting while using bonus action to use second blade?

Is it because both are not held at the same time or something like it? Some wordplay on second and two not being the same word? I honestly do not understand why two weapons are not two weapons fighting. I am not english native so maybe there is something crucial and obvious escaping me.

Also, am I correct to assume that if second blade is not considered two weapons fighting, then it goes like this:

First blade: Attack roll 1d20 + prof + mod; Damage roll 1d6 + mod

Second blade: Attack roll 1d20 + prof + mod; Damage roll 1d4 + mod

Do you add your ability mod to damage for the Soulknife’s second attack?

In D&D 5E, normal Two-Weapon Fighting lets you use your bonus action when you’ve used your action to Attack. It says:

You don’t add your ability modifier to the damage of the bonus attack, unless that modifier is negative.

The new Tasha’s Cauldron subclass Soulknife has a feature where you can create a blade of energy and attack with it, and that says:

After you attack with the blade, you can make a melee or ranged weapon attack with a second psychic blade as a bonus action on the same turn, provided your other hand is free to create it. The damage die of this bonus attack is 1d4, instead of 1d6.

It looks to me that while this is similar to Two-Weapon Fighting, it is not that same, and the normal bonus to damage would apply. Am I right?

Water Elemental grappling a Huge creature, does it take damage from Whelm’s second paragraph?

If a Water Elemental were to use the grappling rules to grapple a Huge creature (since it is Large), would that creature then take damage from this:

At the start of each of the elemental’s turns, each target grappled by it takes 13 (2d8 + 4) bludgeoning damage.

Or does this damage only work against the one Large or two Medium- creatures that get stuck by Whelm?

Huge Article Surplus — $1.99 for 800 words — 5 Second Article Delivery — Zero Spinning

Enter “blackhatdiscount” for 50% off
Enter “blackhatdiscount” for 50% off
New Feature: Also, Get all files in an HTML ready format 
Can I buy more than 50 articles at once?
Yes. We can handle purchases of 1000’s of articles but require you to fill out this form Custom Order. 
What do you mean by 800-word and 1700-word average articles?
There are two article lengths to pick from: 500-1200 words and 1200 to 3000 words. On average, they contain 800 and 1700 words respectively. The 1700 word average articles are about 10% cheaper per 100 words compared to the 800 word avearge articles.
What is your TAT?
We write articles in advanced for you so that they can be delivered instantly. 
What is the quality of your articles?
You can view samples here
Each article is uniquely written. Topics are heavily researched by analyzing over 10 thousand articles on each topic. We then match the keyword density of Google’s top 10 results. This can result in medium quality articles that can be used on any website and are ideal for Google’s spiders. 
You don’t have the topic I am in need of, what can I do?
We are adding new topics weekly and new articles daily. If we don’t have the topic you are looking for please fill out this form Suggest a Niche
How unique are your articles?
Most articles are 100% unique on Copyscape
Skype Contact: pauldemott
NEW Topics Daily

Would the Haste Spell allow you to cast a second, singular weapon attack effecting cantrip (such as Greenflame Blade)?

So the Haste spell in 5e says that the targeted creature

gains an additional action on each of its turns. That action can be used only to take the Attack (one weapon attack only), Dash, Disengage, Hide, or Use an Object action.

This means I technically have a second action, so would that allow me to use the Greenflame Blade cantrip a second time in the same turn (once with the actual action, once with this action) as the cantrip applies to one weapon attack in a similar fashion as a Paladin with Haste could apply Divine Smite onto the Haste-given attack?

Does the second attack from the Dual Wielder feat require an additional action, or a bonus action, to carry out?

I am looking at taking the Dual Wielder feat (PHB, p. 165), but I am not entirely sure as to how it works specifically. It includes the following benefit, among others:

You can use two-weapon fighting even when the one-handed melee weapons you are wielding aren’t light.

Does this second weapon attack require an additional action, or a bonus action, to carry out?