对于给定的查询,我需要将它汇总到 date(dt) 目录级别,但我无法这样做。我尝试了以下查询,但结果为空

For the given query, I need to aggregate it date(dt) ,catalog level but I am unable to do so. I tried the following query but it gave blank result

我需要在日期catalog_id、标志、原始级别聚合的数据,我需要使用数据过滤器

过滤数据
select  CAST( catalog_id as int) as catalog_id
, dt
, CASE
    WHEN date_diff ('day',DATE (users.created), dt) <= 28 
      THEN 'New'
    ELSE 'Old'
  END AS flag
, origin
, count(user_id) as total_views
, count(distinct user_id) as unique_views
from
                     
        (select date(timestamp) as dt, catalog_id, user_id,
        -- case when origin = 'main' and screen='main' then 'FY_feed' 
        case when origin = 'main' then 'FY_feed' 
        when (origin = 'collections' )  OR (origin = 'single_collection')  then 'collections' 
        when origin = 'catalog_search_results' then 'search' 
        -- when origin = 'main' and screen = 'catalogs_filter' then 'catalogs_filter'
        -- when origin = 'notification' and screen = 'main' then 'notification' 
        -- when origin = 'notification' and screen = 'single_collection' then 'collection_notification' 
        when origin = 'notification' then 'notification' 
        when origin = 'banner'  then 'banner' 
        when (origin = 'account' ) OR (origin = 'my_shared_catalogs' )  then 'my_shared_catalogs'
         when origin= 'widget'  then 'widget' 
         when origin= 'wishlist' then 'wishlist'
         when origin= 'visual_search_results' then 'visual_search_results' 
         
        else 'Others' end as origin
        
        from catalog_views_report_final 
        where 
        date(timestamp) >= current_date - 3 
        and date(timestamp) <= current_date
        ) v 
        
LEFT join users on users.id = v.user_id
group by 
dt,
CASE
  WHEN date_diff ('day',DATE (users.created), dt) <= 28
    THEN 'New'
  ELSE 'Old'
END
, CAST( catalog_id as int)
, origin
LIMIT 10
select  CAST(catalog_id as int) as catalogs, dt, CASE
               WHEN date_diff ('day',DATE (users.created), dt) <= 28 THEN 'New'
               ELSE 'Old'
             END AS flag , origin, count(user_id) as total_views, count(distinct user_id) as unique_views (select date(timestamp) as dt, catalog_id, user_id,
-- case when origin = 'main' and screen='main' then 'FY_feed' 
case when origin = 'main' then 'FY_feed' 
when (origin = 'collections' )  OR (origin = 'single_collection')  then 'collections' 
when origin = 'catalog_search_results' then 'search' 
-- when origin = 'main' and screen = 'catalogs_filter' then 'catalogs_filter'
-- when origin = 'notification' and screen = 'main' then 'notification' 
-- when origin = 'notification' and screen = 'single_collection' then 'collection_notification' 
when origin = 'notification' then 'notification' 
when origin = 'banner'  then 'banner' 
when (origin = 'account' ) OR (origin = 'my_shared_catalogs' )  then 'my_shared_catalogs'
 when origin= 'widget'  then 'widget' 
 when origin= 'wishlist' then 'wishlist'
 when origin= 'visual_search_results' then 'visual_search_results' 
 
else 'Others' end as origin

from catalog_views_report_final 
where 
date(timestamp)='2021-06-08'
) v 

LEFT join users on users.id = v.user_id

group by 
1,2,3,4)



group by 1,2