select name,max(age) as age from cx where name is not null

解决方案 »

  1.   

    cgaga(红枫剪影):我试过了!这样不行的!请路过这里的各位大哥好好看一下。我用的是access.
      

  2.   

    select name,max(age) as maxage from cx where name<>'' group by name
      

  3.   

    上面不太对
    select name,age from cx where (not isnull(name)) and age=(select max(age) from 
    cx)
      

  4.   

    select name,max(age) as maxage from cx where name<>'' group by name 和select name,max(age) as age from cx where name is not null 也不行
      

  5.   

    ozw(沧浪客):you are right!!! thank you very mach.!!!
      

  6.   

    如果只要最大的一条
    试试
    SELECT TOP 1 Name,Age
    FROM CX
    ORDER BY Age DESC;
      

  7.   

    "select max(age) as maxage  from cx where name is not null   "成功了,我看到这个贴子时还没有人回复,现在已经有这么多了不过上面那段在我机器通过了,我用的也是Access数据库
      

  8.   

    snakeegg(蛇蛋)如果这样NAME就显示不出
      

  9.   

    同意Hanson_bati_zhu(Hanson_bati_zhu)
      

  10.   

    我也正在奇怪,为什么在max前面加上name就出错呢,怎么回事啊
      

  11.   

    ozw(沧浪客):你好!我还有一个问题!你看。表的结构是这样的!!
       name      age
       aaa       12
       aaa       14
       aaa       18
       adi       12
       adi       19
        .         .
        .         .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的
    谢谢了!路过此处的大虾请看一看!!!
      

  12.   

    snakeegg(蛇蛋) :不行的!你写的折断代码不行的!!我没有通过!!
      

  13.   

    试试
    SELECT NAME,Max(AGE) AS AGE FROM TEST
    WHERE NAME <> NULL AND NAME <> ''
    GROUP By NAME;
      

  14.   

    select name, max(age) from cx where (name is not null)
      

  15.   

    我还有一个问题!你看。表的结构是这样的!!
      name      age
      aaa      12
      aaa      14
      aaa      18
      adi      12
      adi      19
        .        .
        .        .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的,并且把所有名字不为空的和年龄都选出来!!
    谢谢了!路过此处的大虾请看一看!!! 
      

  16.   

    我还有一个问题!你看。表的结构是这样的!!
      name      age
      aaa      12
      aaa      14
      aaa      18
      adi      12
      adi      19
        .        .
        .        .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的,并且把所有名字不为空的和年龄都选出来!!
    谢谢了!路过此处的大虾请看一看!!! 
      

  17.   

    "select name,age as maxage from cx where age in (select max(age) from cx where name is not null)"再不好使我就不活了,哥们 @_@
      

  18.   

    snakeegg(蛇蛋):大哥!你能不能在看看这个问题!!
    我还有一个问题!你看。表的结构是这样的!!
      name      age
      aaa      12
      aaa      14
      aaa      18
      adi      12
      adi      19
        .        .
        .        .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的,并且把所有名字不为空的和年龄都选出来!!
    谢谢了!路过此处的大虾请看一看!!! 
      

  19.   

    我还有一个问题!你看。表的结构是这样的!!
      name      age
      aaa      12
      aaa      14
      aaa      18
      adi      12
      adi      19
        .        .
        .        .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的,并且把所有名字不为空的和年龄都选出来!!
    谢谢了!路过此处的大虾请看一看!!! 
    紧急!!!1
      

  20.   

    select top 1 from cx where name is not null
      

  21.   

    这样不行吗?
    SELECT NAME,Max(AGE) AS AGE FROM TEST
    WHERE NAME <> NULL AND NAME <> ''
    GROUP By NAME;
      

  22.   

    我还有一个问题!你看。表的结构是这样的!!
      name      age
      aaa      12
      aaa      14
      aaa      18
      adi      12
      adi      19
        .        .
        .        .
    是这样的。就是name中有很多重名的要从中选出每个名字中 age最大的,并且把所有名字不为空的和年龄都选出来!!
    谢谢了!路过此处的大虾请看一看!!! 
    紧急!!!1 
      

  23.   

    Hanson_bati_zhu(Hanson_bati_zhu):完全正确!!!!!!谢谢!!!!!!!
    能给我说一下 NAME <> ''是什么意思???我在加分!我肯定给分!!
      

  24.   

    NAME <> ''
    应该改为
    RTrim(NAME) <> ''
      

  25.   

    能解释一下 rtrim(name)<>'' 是什么意思??
      

  26.   

    就是你要求的“名字不为空”啊
    “空”有两种状态
    一种是NULL,一种是为长度为0的字符串
    所以用了NAME <> NULL AND RTrim(NAME) <> ''
    来判断