Created
September 16, 2013 21:22
-
-
Save mazelife/6586773 to your computer and use it in GitHub Desktop.
Selects 10 product/name pairs for each vendor across all vendors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Also, wish I could do a push request!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just got 200 rows in
50121
seconds for the star2.sql data dump... this is not an optimal query for big tables!