这样行不:
SQL>select col_1,max(col_2),col_3,max(col_4),max(col_5)
SQL>from table_name 
SQL>group by col_1,col_3;
下次请把详细的表结构名,详细需求贴出来,
这样大家才能找到问题的根本所在。

解决方案 »

  1.   

    select 字段1,max(字段2),字段3,字段4..... from tabname group by 字段1
    有这样写法,急也没用,语法已错,搞清楚自已需求
      

  2.   

    用如下解决方法(已调试通过):
    select a.字段1,max 字段2别名,b.字段3,b.字段4... from (select 字段1,max(字段2) max from tablename group by 字段1) a,tablename b where a.字段1=b.字段1 and a.max=b.字段2;
      

  3.   

    多谢大家关心,我的表结构是这样的:
    字段1     字段2     字段3  .........
    aa        time1     value1
    aa        time2     value2
    aa        time3     value3
    bb        time4     value4
    bb        time5     value5
    cc        time6     value6
    cc        time7     value7
    ........
    time和value等其他值都互不相同,且value为bolb字段
    现想建一个视图,是该表的不含重复记录的集合(重复记录只取time值最大的)
    谢谢!
      

  4.   

    有没有试呀?
    select a.字段1,max 字段2别名,b.字段3,b.字段4... from (select 字段1,max(字段2) max from tablename group by 字段1) a,tablename b where a.字段1=b.字段1 and a.max=b.字段2;
      

  5.   

    SQL> select * from emp; DEPTNO SAL                  TEST1          TEST2          TEST3
    ------- ------------------ ----------- --------------   -------------
        10 17-12-2003 11:22:51  afojefs    zdsvcjoiadsfwe   sadfqweofvqof
        10 17-12-2003 11:23:01  asdfomq    vfqewiof         awerovoniqfhj
        20 17-12-2003 11:23:13  vsoowqe    qwoerjafojaqe    asdfoqwerjoaw
        20 17-12-2003 11:23:25  asofdjwo   asefqwejojr      vojwqeoriqwe
        30 17-12-2003 11:23:37  svfoqlfj   asdfjqwoerjr     fvojqweorjqwer
        30 17-12-2003 11:23:54  assodfvf   qwerfojqweife    wqoefjqwfno6 rows selectedSQL> select bbb.* from (select deptno,max(sal) sal from emp
      2  group by deptno) aaa,emp bbb
      3  where aaa.sal=bbb.sal   --比较日期值;
      4  ; DEPTNO SAL                  TEST1          TEST2          TEST3
    ------- ------------------ ----------- --------------   -------------
        10 17-12-2003 11:23:01  asdfomq    vfqewiof         awerovoniqfhj
        20 17-12-2003 11:23:25  asofdjwo   asefqwejojr      vojwqeoriqwe
        30 17-12-2003 11:23:54  assodfvf   qwerfojqweife    wqoefjqwfno以上是仿照你的需求建的表emp,看能不能满足你的需求。