Given this dataset of teams

```
id | team_name | points
1  | A         | 10
2  | B         | 20
3  | C         | 30
4  | D         | 40
5  | E         | 50

```

i can use this query with a window function to get the average of the top 3 teams

```
with top_3 as(
  select * 
  from teams 
  order by points desc 
  limit 3
)

select *, avg(points) over() as top3_average
from top_3

```

Is is possible to use window functions on only the top 3 rows from the dataset? 

I tried with, but that certainly doesn't work.

```
OVER(... limit 3)

```

Here is a working [sqlfiddle](http://www.sqlfiddle.com/#!15/badc9/2)

---

*Just to be clear I know I can do this with a subquery like so. I'm more interested in learning if this is possible with a window function*

```
select *, avg(points) over() as top3_average
from teams
where id in
  (select id 
   from teams 
   order by points desc 
   limit 3)

```