.

working with aggregates in sql

here is an example of using aggregates inline:

select name, surname, score - avg(score) over (partition by surname) as difference
order by surname, difference

– degenerate case:
or if you don’t want to partition just use a constant for partition:

select name, surname, score - avg(score) over (partition by 0) as difference
order by surname, difference

What's your thoughts on this?

*

Protected by WP Anti Spam