tags:

views:

41

answers:

1

Hello,

I am looking for a little help writing a T-SQL query. It's been a while since I've done something like this and my brain is forgetting what I need to do.

I have a table with the following data that I need a query to get Col1, Max(Col2), Min(Col3). So that's for each distinct col1 I want to get the max col2 and min col3.

Example for the table below, I want to see:

    0001, 1, 01-10-2009
    0002, 2, 02-10-2009
    0003, 0, 04-10-2009

Col1   Col2   Col3
0001   0      10-10-2009
0001   1      01-10-2009
0002   1      02-10-2009
0002   2      03-10-2009
0003   0      04-10-2009

Thanks!

+8  A: 
SELECT COL1, MAX(COL2), MIN(COL3)
FROM table
GROUP BY COL1
Mike M.
Duh... I feel like a moron lol :) I think that'll do it, gonna test a little more and mark as answer.
Dave
When you're away from the game for a while, nothing comes easy :)
Mike M.