- I have a few queries get the ID numbers of rows that will be deleted in the future.
- The row numbers are put into a string and placed in the query below (where you see "2").
I want the results to ignore the rows (as though they have already been deleted).
SELECT MAX(T1.id) AS MAXid FROM transactions AS T1 WHERE id NOT IN ( 2 ) GROUP BY T1.position ORDER BY T1.position
My guess is that I need to replace the "WHERE" line with "HAVING", but I cannot find "NOT HAVING" syntax.
The way this query is currently written, it will not return a row for T1.position if the max id for the position is listed in the WHERE clause.
How do I get this query to give me the max ID for the T1.position while overlooking the rows with IDs listed in the WHERE clause?
WHERE
withHAVING
". TheHAVING
clause should appear in a different place in the query - after theGROUP BY
andORDER BY
. BUT - as titanoboa says, I am not sureHAVING
is what you are looking for. So I vote for him! – Dementia