我如何创建查询以在不计算重复项的情况下以沙丘上的以太坊上展示新创建的ERC-20合同的开发?
我正在尝试展示以太坊上新创建的ERC-20智能合约的开发。为此,我使用的是分析平台沙丘,该沙丘提供了几个用于SQL查询的数据库。
我的问题是以下问题:
我有一张表格显示特定合同的所有交易。每笔交易都由表的一行显示,并包含以下列“ date”,“ smart_contract_address”(唯一ERC20智能合约的标识符)和交易的其他详细信息作为“金额”
简化示例:
日期 | q1 | smart_contract_address |
---|---|---|
/ | 20222 | 50 |
B | Q1/2022 | 20 |
C | Q2/2022 | 10 |
A | Q1/2022 | 5 |
A | Q2/2022 | 7 |
我想计算不同的不同Smart_Contract_Addresses每季度。我想确保每个地址仅计数一次。计数地址后,它应该被“忽略”,不仅是在同一季度出现,而且在以下季度出现。
在我的示例中,我的预期查询结果看起来像:
Quarter | Count |
---|---|
Q1/2022 | 2 |
Q2/2022 | 1, |
但是我的查询并未显示我的预期结果。使用独特的关键字,我确保在每个季度中仅计算一次地址,但在以下几个季度中会再次计数...
您能告诉我如何调整我的查询,以至于我只计算一次相同的地址他们第一次出现的季度?
with everything as (
select contract_address as ca, date_trunc('quarter', evt_block_time) as time
from erc20."ERC20_evt_Transfer"
)
select time, count(distinct ca) as "Count"
from everything
group by time
I am trying to display the development of new created ERC-20 smart contracts on Ethereum. For this purpose I am using the Analytics platform Dune which provides a several databases for SQL querying.
My problem is the following one:
I have a table that shows all transactions of a specific contract. Every transaction is displayed by one row of the table and contains following columns "date", "smart_contract_address"(identifier for a unique ERC20 smart contract) and other details of the transaction as "amount"
Simplified example:
smart_contract_address | date | Amount |
---|---|---|
A | Q1/2022 | 50 |
B | Q1/2022 | 20 |
C | Q2/2022 | 10 |
A | Q1/2022 | 5 |
A | Q2/2022 | 7 |
I would like to count the different smart_contract_addresses per quarter. I want to make sure that every address is only counted once. After an address was counted it should be "ignored", not only if it appeared in the same quarter, but also in following ones.
For my example my expected query result would look like:
Quarter | Count |
---|---|
Q1/2022 | 2 |
Q2/2022 | 1 |
However my, query does not show my expected result. With the distinct keyword I make sure that in every quarter one address is only counted once, but will be counted again in the following quarters...
Can you tell me how I need to adjust my query that I count same addresses only once and for the quarter where they appeared for the very first time?
with everything as (
select contract_address as ca, date_trunc('quarter', evt_block_time) as time
from erc20."ERC20_evt_Transfer"
)
select time, count(distinct ca) as "Count"
from everything
group by time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
try this: