create table jilu 
(
    时间日期 datetime primary key, 
    数目 integer not null default 0
)
insert into jilu values ('2007-01-10 10:10:11', 0)
insert into jilu values ('2008-01-10 10:10:11', 0)
insert into jilu values ('2008-12-10 10:10:11', 0)如何只返回
2008-12-10 10:10:11     0 这条记录

解决方案 »

  1.   

    SELECT *
    FROM jilu 
    WHERE 时间日期=(
              SELECT MAX(时间日期)
              FROM jilu
          )
      

  2.   

    select top 1 * from jilu ordery by datetime desc
      

  3.   

    create table jilu 

        时间日期 datetime primary key, 
        数目 integer not null default 0 

    insert into jilu values ('2007-01-10 10:10:11', 0) 
    insert into jilu values ('2008-01-10 10:10:11', 0) 
    insert into jilu values ('2008-12-10 10:10:11', 0) SELECT *
    FROM jilu 
    WHERE 时间日期=(
              SELECT MAX(时间日期)
              FROM jilu
          )
    DROP TABLE jilu/*
    时间日期                    数目
    ----------------------- -----------
    2008-12-10 10:10:11.000 0(1 行受影响)
    */
      

  4.   

    create table jilu 

        时间日期 datetime primary key, 
        数目 integer not null default 0 

    insert into jilu values ('2007-01-10 10:10:11', 0) 
    insert into jilu values ('2008-01-10 10:10:11', 0) 
    insert into jilu values ('2008-12-10 10:10:11', 0) 如何只返回 
    2008-12-10 10:10:11    0 这条记录
    select top 1 from jilu order by 时间日期 desc
      

  5.   

    create table jilu 

        时间日期 datetime primary key, 
        数目 integer not null default 0 

    insert into jilu values ('2007-01-10 10:10:11', 0) 
    insert into jilu values ('2008-01-10 10:10:11', 0) 
    insert into jilu values ('2008-12-10 10:10:11', 0) select top 1 * from jilu order by 时间日期 desc--drop table jilu/*
    时间日期                                                   数目          
    ------------------------------------------------------ ----------- 
    2008-12-10 10:10:11.000                                0(所影响的行数为 1 行)
    */
      

  6.   

    create table jilu 

        时间日期 datetime primary key, 
        数目 integer not null default 0 

    insert into jilu values ('2007-01-10 10:10:11', 0) 
    insert into jilu values ('2008-01-10 10:10:11', 0) 
    insert into jilu values ('2008-12-10 10:10:11', 0) 
    select * from jilu t where not exists(select 1 from jilu where 数目=t.数目 and 时间日期>t.时间日期)
    drop table jilu
    /*时间日期                                                   数目          
    ------------------------------------------------------ ----------- 
    2008-12-10 10:10:11.000                                0(影響 1 個資料列)
    */
      

  7.   

    select top 1 * from jilu ordery by datetime desc