Your last snippet should work, i.e. _grouparray should be an array of all units in the group, and _theunit should be the second (when using "select", the index starts with 0) unit among them. This should work fine as long as your group contains two or more units. With
_N = count _grouparray
you can determine the number of units. The allowed range of ID numbers is then 0, 1, ..., _N -1.
Why do you check for "NOT(alive leader patrol1)"? This should only be true if the whole patrol1 group is dead.
A nice way to solve problems like your first one, is to use the "extended" count command:
?("leader _patrol KnowsAbout _x > 2" count (units _groups)) > 0: goto "detected"
This counts how many units of _group have a knowsAbout value larger than 2. If there is atleast one unit, "detected" is triggered. This should be equivalent to your snippet.
The _x in the "condition string" is a placeholder for the elements to be counted and is reserved.