with tab1 as (
select BUYER
,PRICE
,NFT_ID
from flow.core.ez_nft_sales
where NFT_COLLECTION='A.e4cf4bdc1751c65d.AllDay'
and BLOCK_TIMESTAMP<'2022-11-24'
and TX_SUCCEEDED='TRUE'
and BUYER in ('0xc4719ab3f4c3db69','0xed8707e2ae5bba5a','0x0b9986cd8fea9c61','0x64afebe42165be6e'
,'0x2b5852e21f5cf0af','0xc61bb210bce9722c','0xddfbe848a81b2236','0x2e1a03b4e98c43e3','0xb8eab8b330b6d8f3','0x9cf0e3443ebc8bf9')),
tab2 as (
select
case
when TEAM in ('Minnesota Vikings','New England Patriots','Dallas Cowboys','New York Giants','Detroit Lions','Buffalo Bills')
then 'Belonging to the teams that played on Thanksgiving Day' else 'Other Teams' end as team_type
,NFT_ID
,PLAYER
,TEAM
from flow.core.dim_allday_metadata)
select TEAM,sum(PRICE)as volume,count(distinct tab2.NFT_ID)as nft_count
from tab1
left join tab2
on tab1.NFT_ID=tab2.NFT_ID
group by 1
order by 3 desc
limit 10