A_Elric
A_Elric

Reputation: 3568

MySql conditional

I can't quite get this query to work how I want it to.

IF(h.STATUS="On-Login-Screen") OR (h.STATUS="IE-Window-Missing") 
SELECT MAX(h.TIME) limit 1 AS LastDown

Essentially I want to check the last time h.Status equaled one of the above things, and get the most recent time when it does equal one of those things as a variable named LastDown.

Upvotes: 0

Views: 70

Answers (1)

rs.
rs.

Reputation: 27417

Try this:

SELECT MAX(h.TIME) AS LastDown
FROM TABLENAME
WHERE (h.STATUS='On-Login-Screen') OR (h.STATUS='IE-Window-Missing') 
--limit 1 

Or

SELECT MAX(h.TIME) AS LastDown
FROM TABLENAME
WHERE h.STATUS IN ('On-Login-Screen','IE-Window-Missing') 

Upvotes: 1

Related Questions