开发者

I need help with a sql query

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!


SELECT COL1, MAX(COL2), MIN(COL3)
FROM table
GROUP BY COL1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜