SERIAL_NUMBER  WEPKEY    SSID     PASSWORD SBBS                I_TIME
0C4C397581CB apjkzhcp 4KYP          vnnhx    350000C4C39758199 2011/10/26 20:10:14
0C4C397581CB uwjngn62 YfDw          gmeag    340000C4C397581CB 2011/10/26 20:20:14像上面的表 :sajet.iac_oem我想查出最新一笔的资料我的SQl是这样的,但是不知道为什么会报:ora-00913 :too many valuesselect  b.wepkey, b.ssid, b.password, b.sbbs
  from sajet.iac_oem b
 where b.serial_number  in (select SERIAL_NUMBER,
                                max(to_char(i_time, 'YYYY/MM/DD HH24:MI:SS')) i_time
                           from sajet.iac_oem t
                          group by SERIAL_NUMBER)请高手帮忙,该怎么修改。谢谢

解决方案 »

  1.   

    in里面的子查询多了i_time ??
      

  2.   

    b.serial_number in (select SERIAL_NUMBER,i_time  from sajet.iac_oem t)
    1对多了。
      

  3.   

    不是多了一个 i_time ,而是应该 in 前面 加上一个 i_time
      

  4.   


    select * from (
    select wepkey, ssid, password, sbbs
      from sajet.iac_oem 
      order by i_time desc) where  rownum=1
    排序取第一个值就是最新的了
    或者按你的写法,但要修改一下select b.wepkey, b.ssid, b.password, b.sbbs
      from sajet.iac_oem b
     where b.serial_number,[color=#FF0000]b.i_time [/color]in (select SERIAL_NUMBER,max(i_time) i_time  from sajet.iac_oem t
      group by SERIAL_NUMBER)
      

  5.   

    我的记录不止一条的,只是里面有两条是重复的,但是必须去时间为最近的那一笔,所以您写的SQL 好像不能实现,然后修改的那个SQl ,运行了一下,也是报错的
      

  6.   

    select b.wepkey, b.ssid, b.password, b.sbbs
      from sajet.iac_oem b
     where b.serial_number in (select SERIAL_NUMBER  from sajet.iac_oem t
      group by SERIAL_NUMBER)
      

  7.   

    SELECT b.wepkey,sword, b.sbbs FROM(SELECT DISTINCT  (b.wepkey),sword, b.sbbs
      from sajet.iac_oem b
    ORDER BY b.I_TIME) t
    GROUP BY  t.wepkey,t.sword, t.sbbs
      

  8.   

    SELECT T.WEPKEY, T.SWORD, T.SBBS
      FROM (SELECT DISTINCT (B.WEPKEY), SWORD, B.SBBS
              FROM SAJET.IAC_OEM B
             ORDER BY B.I_TIME) T
     WHERE ROWNUM <=1
     GROUP BY T.WEPKEY,
              T.SWORD,
              T.SBBS
      

  9.   

    select b.wepkey, b.ssid, b.password, b.sbbs
      from sajet.iac_oem b
     where b.serial_number,ROWID in (select SERIAL_NUMBER,MIN(ROWID)  from sajet.iac_oem t
      group by SERIAL_NUMBER)
      

  10.   

    ---------------上 有误--取靠前的值,如果取后值,改成max
    select b.wepkey, b.ssid, b.password, b.sbbs
      from sajet.iac_oem b
     where (b.serial_number,ROWID) in (select SERIAL_NUMBER,MIN(ROWID)  from sajet.iac_oem t
      group by SERIAL_NUMBER)
      

  11.   

    上面ORDER BY T.T_time 后面加个DESC 这个给忘记了!
      

  12.   

    where b.serial_number in (select SERIAL_NUMBER,
      max(to_char(i_time, 'YYYY/MM/DD HH24:MI:SS')) i_time
      from sajet.iac_oem t
      group by SERIAL_NUMBER)select SERIAL_NUMBER,max(to_char(i_time, 'YYYY/MM/DD HH24:MI:SS')) i_time查出来是两列
    b.serial_number in 是一列
    改成:
    where (b.serial_numbe,b.i_time) in (select SERIAL_NUMBER,
      max(to_char(i_time, 'YYYY/MM/DD HH24:MI:SS')) i_time
      from sajet.iac_oem t
      group by SERIAL_NUMBER)