34,587
社区成员
发帖
与我相关
我的任务
分享
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 個資料列)
*/
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 行)
*/
select top 1 from jilu order by 时间日期 desc
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 行受影响)
*/
SELECT *
FROM jilu
WHERE 时间日期=(
SELECT MAX(时间日期)
FROM jilu
)