James Murray
James Murray

Reputation: 1

How to Get Top 100 Products by Impressions? | Google Merchant Center BigQuery SQL

I have two GMC tables in my BigQuery instance (ProductPerformance_ and Products_). I have this query below:

WITH Base AS (
  SELECT
    a.product_id,
    a.title AS product_title,
    b.description,
    SUM(a.impressions) AS total_impressions
  FROM
    `MYPROJECT.gmc.ProductPerformance_MYID` a
  LEFT JOIN
    `MYPROJECT.gmc.Products_MYID` b ON a.product_id = b.product_id
  WHERE
    a._PARTITIONTIME >= "2024-04-01"
    AND a.destination = 'ADS'
    AND b._PARTITIONTIME >= "2024-04-01"
  GROUP BY
    a.product_id, a.title, b.description
  ORDER BY
    total_impressions DESC
  LIMIT
    100
)

SELECT
  product_id,
  product_title,
  description,
  total_impressions
FROM
  Base;

My hope was that this would return the top 100 items by ad impressions. But the final select only returns 38 products. Any glaring reason why that would be the case?

These are the only two tables I have access to in BigQuery.

Upvotes: 0

Views: 30

Answers (0)

Related Questions