Using cardano-db-sync, I want to get the number of delegators given a pool_id.
For example, this pool has 22 delegators. https://cardanoscan.io/pool/18109d01af0c5c4495a64a9de061ad621156729afc699128c0ceee0e?tab=delegators
However, when I used the following query, the result did not match. The following query returns 66 unique values of stake_address.hash_raw.
select pool_hash.view,stake_address.hash_raw::text, stake_address.view, delegation.active_epoch_no, delegation.slot_no from delegation, pool_hash, stake_address where delegation.pool_hash_id = pool_hash.id and delegation.addr_id =stake_address.id and pool_hash.view ='pool1rqgf6qd0p3wyf9dxf2w7qcddvgg4vu56l35ez2xqemhqun2gn7y'
I want to ask that
It seems the the table
delegationalso contains the delegation history, not only the delegation at current time? If so, which table should I use to be able to filter out to get only the number of current delegators.
How can I get the number of delegators w.r.t a pool_id
(2.1) at the current epoch
(2.2) for each epoch