1. search 2nd pattern after a pattern and summarize stats

I have two questions. I am sure one of the Guru will be able to help either one or both.

  1. Find 2nd occurance of pattern= "Bind variable after pattern="ABN USER Admin"
    ......
    ABN USER Admin <--- I know this string
    .....
    Bind variable
    ...
    ..
    Bind variable <-- Want to print this string(2nd occurnace)

  2. I have lot of statement with timing information and want to summarize in some brackets. e.g
    0 to 10 seconds 10
    10 to 20 seconds 12
    20 to 50 second 3

e,g
actual data
SQL Statement execution time 0.001 Seconds
SQL Statement execution time 10.12 Seconds
SQL statement execution time 22 Seconds
SQL statement execution time 5.08 Seconds
SQL statement execution time 12 Seconds
SQL statement execution time 19.08 Seconds
SQL statement execution time 20.01 Seconds

output expected
0 to 10 seconds --> 2
10 to 20 seconds -->3
20 to 30 seconds --> 2

Thanks in advance for your time.

For the 1st question, I am not quite clear about what you want to achieve, for the 2nd question:

awk '{ 
 if($5<=10) {++b1} 
 else if($5>10&&$5<=20) {++b2} 
 else if($5>20&&$5<=30) {++b3} 
 else {++b4} } 
END { 
 printf "0 to 10 seconds --> %d\n", b1;
 printf "11 to 20 seconds --> %d\n", b2;
 printf "21 to 30 seconds --> %d\n", b3;
 printf "more than 30 seconds --> %d\n", b4;
}' infile

Yes, your answer exactly does what is needed. Thank you very much.

For question 1 I need to file 2nd occurance of particular word starting from a particular word in file.
e.g find the second occurance of pattern2 after pattern1

1.pattern2
2.pattern2
3.pattern1
4.pattern2
5.pattern2

output 5.pattern2 (this is 2nd occurance from pattern1)

awk '/pattern1/{cnt=0;p=1;next} /pattern2/{cnt++;if(p && cnt==2){print $0;p=0}}' inputFile
awk '/pattern1/{c=2} /pattern2/&& c--==1' file