Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Forked from mazelife/spinnaker
Last active December 23, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbengfort/6588786 to your computer and use it in GitHub Desktop.
Save bbengfort/6588786 to your computer and use it in GitHub Desktop.
Creates a test data set from star delta 0 - selecting ten sample coalesced urls and product names from the shelves for each vendor.
SELECT product, url FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY vendor ORDER BY product DESC) AS r, t.* FROM
(SELECT vendor.name AS vendor, product.name AS product, COALESCE(shelf.detail_url, shelf.buy_url, NULL) AS url
FROM shelf
JOIN product ON product.id = shelf.product_id
JOIN vendor ON vendor.id = shelf.vendor_id)
AS t)
AS x
WHERE x.r <= 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment