我想用美元来计算交易成本
对于多个最近的交易
在Rootstock区块链上.
我有一个带有令牌的PostgreSQL数据库表
价格reports.token_prices
我从其中 Select 了value
以美元为单位的最新可用RBTC价格:
select tp.price_in_usd
from reports.token_prices tp
where tp.chain_id = 30
and tp.coingecko_token_id = 'rootstock'
order by tp.dt desc
limit 1
(请注意,tp.dt
是时间戳)
查询结果:
16995.771
然后我有一个表,里面有所有的交易,
chain_rsk_mainnet.block_transactions
,
我从其中 Select 煤气费
关于最近的5个问题:
select
bt.fees_paid
from chain_rsk_mainnet.block_transactions bt
order by bt.block_id desc, bt.tx_offset
limit 5
(请注意,我没有使用时间戳,而是使用bt.block_id
和bt.tx_offset
作为交易顺序)
结果:
0
4469416300800
4469416300800
16450260000000
0
现在我想把每个数字相乘 通过第一次查询的结果. 我如何在SQL中做到这一点?