Oracle “Partition By” Keyword

前端 未结 6 888
不思量自难忘°
不思量自难忘° 2020-11-29 14:22

Can someone please explain what the partition by keyword does and give a simple example of it in action, as well as why one would want to use it? I have a SQL

6条回答
  •  暖寄归人
    2020-11-29 15:04

    the over partition keyword is as if we are partitioning the data by client_id creation a subset of each client id

    select client_id, operation_date,
           row_number() count(*) over (partition by client_id order by client_id ) as operationctrbyclient
    from client_operations e
    order by e.client_id;
    

    this query will return the number of operations done by the client_id

提交回复
热议问题