Window function in MySQL queries

Is there a way to dynamically use window functions in MySQL queries in a SELECT query itself? (I know this is possible in PostgreSQL).

For example, here is the equivalent query in PostgreSQL:

SELECT c_server_ip, c_client_ip, sum(a_num_bytes_sent) OVER 
   (PARTITION BY c_server_ip) FROM network_table;

However, what would be the corresponding query in MySQL?

+3
source share
1 answer

Hope this might work:

select A.c_server_ip, A.c_client_ip, B.mySum
 from network_table A, (
  select c_server_ip, sum(a_num_bytes_sent) as mySum
  from network_table group by c_server_ip
 ) as B
where A.c_server_ip=B.c_server_ip;
+2
source

All Articles