quasi random (kaolinfire) wrote,
quasi random

Is it just because I'm sick?

I am sick. It is unpleasant.


There has GOT to be an easier way to do this--doesn't there?

I just spent _two hours_ on this, so I don't know. Trying to get the id associated with the minimum sort order of each set of images for a given set of "stock number"s.

SELECT min(i1.id) as id, i1.stock_number, i1.sort FROM inv_image_groups i1, (SELECT max(sort) as sort, stock_number FROM inv_image_groups GROUP BY stock_number) as i2 WHERE i1.stock_number IN (SELECT distinct stock_number from inv_image_groups) AND i1.stock_number = i2.stock_number and i2.sort = i1.sort GROUP BY i1.stock_number;

Essentially, there can be any number of images associated with a given vehicle, each with a sort order so we know how to display them. When listing a bunch of vehicles, I want to pull each image with the lowest sort order for each vehicle, to just show that one thumbnail.

Tags: handbrewed, overworked, sick, sql, valencia acura

  • feedback loops

    Ah, feedback loops. I was kind of out of sorts, yesterday, and for some reason had a lot of diet coke (to try to feel better, though I "knew" it…

  • What would I say?

    What would I say, if I were here? It's 2014, almost 2015—though on and off this year, I've been sure it was 2015. Something about that number. Next…

  • a list of games....

    A friend recently asked for a list of all the games I have available. And I'd made most of this list up a week ago, for someone else, and figured,…

  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.