• Dbloc (1/31/2012)


    I must mention that there are some other columns in the table that are specific to each row. I should have mentioned this right away but forgot. sorry 🙁

    So having min and max date in the same row wouldn't work.

    I would need something like this:

    bldgid userID dateid score1 score2

    1 1 123 90 99

    1 1 124 89 88

    1 1 125 99 99

    .

    .

    .

    I need a query that will pull the first row and the last due to the dateid being the min and the max...

    Hope this helps. Sorry for the confusion.

    It does, but it's harder to hand you an example of that. You're looking for the equivalent of 'last row' in a logging table. You'll want to use something similar to SELECT bid, uid, MIN() UNION Select bid, uid, MAX() as a subquery to join the main table back against. If you setup sample schema and data like you'll find in the first link in my signature you'll get tested code in return (usually).

    It's a bit difficult to explain otherwise if that snippet doesn't make sense.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA