Here's the code that I am using. 

```
  Select max(heart_rate) as Max_heart, Count(*) from exercise_logs 
  where heart_rate between (0.5*Max_heart) and (0.9*Max_heart);

```

I am new with SQL, but I think this would have been easy with something like R. Anyways, since I need to get this done in SQL, any suggestions on how do I do this? 

My data looks like this

```
  type            minutes calories heart_rate
  biking          30      100      110
  biking          10       30      105
  dancing         15      200      120
  dancing         15      165      120
  tree climbing   30       70       90
  tree climbing   25       72       80
  rowing          30       70       90
  hiking          60       80       85

```