Answers for "Subquery Vs CTE1"

0

Subquery Vs CTE1

WITH avg_pet_count_over_time AS (
  SELECT
  	cat_id, 
  	MAX(timestamp)::DATE AS max_pet_date,
    MIN(timestamp)::DATE AS min_pet_date 
  FROM cat_pet_fact
  GROUP BY cat_id
)
SELECT 
  cat_name, 
  max_pet_date 
FROM cat_dim
LEFT JOIN avg_pet_count_over_time
ON cat_dim.cat_id = avg_pet_count_over_time.cat_id;
Posted by: Guest on July-17-2021

Browse Popular Code Answers by Language