SELECT
count(address) as Total_addresses,
sum(balance_usd) as Total_balance_USD,
sum(balance) as Total_balance_LUNA
FROM (
SELECT
address,
balance_usd,
balance
FROM
terra.daily_balances
WHERE
currency = 'LUNA'
AND balance_type = 'liquid'
AND balance > 0
AND to_date(date) = '2022-01-27'
ORDER by 2 desc
)