Q:

Select the count of entries that have Max value in a range

I need to get the count of myIndex which it has the max Value per hour, for example:
MyIndex f_hour  maxi
8187    10  70**  ++1 for 10h and 8187
8178    10  50
8184    10  46
8190    10  46
8180    10  40
8179    10  33
8185    10  30
8183    10  26
8181    10  23
8182    10  20
8186    10  20
8177    10  13
8189    10  6
8188    10  3
**8188  11  80** ++1 for 11h and index 8188
8187    11  60
8180    11  53
8186    11  50
8179    11  46
8190    11  46
8178    11  43
8181    11  33
8184    11  33
8189    11  33
8183    11  26
8185    11  23
8182    11  16
8177    11  13
**8187  12  73** now 8187 has at 10h the max value and now at 12h too, so 2 !! 
8188    12  66
8179    12  60
8190    12  56

the result will be like
MyIndex     Count
8187          2 (times)
8188          1 (time)

How can I do this?

A:

This is a histogram of histogram query.  You seem to want to count the number of hours that each value appears as a maximum.  This ends up being a double group by:
select maxvalue, count(*) as numhours
from (select hour, max(value) as maxvalue
      from table t
      group by hour
     ) t
group by maxvalue
order by maxvalue;

EDIT:
I see, you don't want the histogram of values but of indexes.  You can do that with window functions, which are ANSI standard and available in most (but not all) databases:
select myindex, count(*) as numhours
from (select t.*, row_number() over (partition by hour order by value desc) as seqnum
      from table t
      group by hour
     ) t
where seqnum = 1
group by myindex
order by myindex;

