you can use CASE WHEN THEN statement to achieve this functionality. an example for this is as follows.
SET SelectStmt =
"SELECT COUNT(distinct(C.LocationID))AS 'Total Locations',
CASE
WHEN Parameter1 = 'all'
THEN --do this
--IF((select max(TIMESTAMPDIFF(minute, C1.LastContact, NOW() ))
--from computers c1 where c1.locationid = c.locationid) >= @TimeToFail,'Fail','OK')
--AS 'Status',
WHEN Parameter1 = 'fail'
THEN --do this
WHEN Parameter1 = 'ok'
THEN --do this
END AS 'Status'
FROM
Computers AS C ";
SET WhereClause = CONCAT(WhereClause, " IFNULL(TIMESTAMPDIFF(minute, C.LastContact, NOW()),0) ",
'>=',@TimeToFail);
SET GroupBy = " GROUP BY C.LocationID ";
please check and reply if it works.