I have a Select query that returns me the session identifiers of all sessions that have a time of less than 8 days. It works great!
SELECT sessionID FROM session WHERE sessionStatus = 'open' GROUP BY sessionID HAVING MAX(refTime) <= 8;
But I am trying to update the table, so that each record with a session ID that is less than 8 days has its own sessionStatus changed to "closed". From stackoverflow, I know that I cannot update the table that I also select, and that the Have and Group By functions are agate functions that make this more complicated.
I tried this, but not cubes!
UPDATE session
SET sessionStatus='closed'
WHERE sessionID = (select * from (SELECT MAX(sessionID) FROM session where sessionStatus = 'open') as t);
I would really appreciate any help!
source
share