Select a.序号,a.书名,a.阅读时间 from table1 as a inner join ( select 书名,max(阅读时间) as 阅读时间 from table1 group by 书名) as b on a.书名=b.书名 and a.阅读时间=b.阅读时间
select max(序号),书名,max(阅读时间) from table1 group by 书名
select * from table where 书名,阅读时间 in( select 书名,max(阅读时间) from table1 group by 书名 )
谢谢各位大侠,真是sql高手多多啊!!感叹!!!!
SELECT DISTINCT 书名, MAX(阅读时间) AS 阅读时间 FROM TATLE1 GROUP BY 书名
select bookname,max(readdate) from teble1 group by bookname新手也写一个
应该是按书名的降序排列的把,没记错应该是这样: select distinct bookname from table order by bookname desc;
select * from table1 where 阅读时间 in(select max(阅读时间) from table1 group by 书名)
select * from table1 a where not exists (select 1 from table1 where 书名 = a.书名 and 阅读时间 < a.阅读时间 ) select * from table1 a where not exists (select 1 from table1 where 书名 = a.书名 and 序号 < a.序号 )
to playyuer(退休干部 卧鼠藏虫)select 1 到底有啥作用,好象得到的全是1的记录
select * from table1 a where not exists (select 1 from table1 where 书名 = a.书名 and 阅读时间 < a.阅读时间 ) order by a.序号
高手好像写反了: select * from table1 a where not exists (select 1 from table1 where 书名 = a.书名 and 阅读时间 > a.阅读时间 ) select * from table1 a where not exists (select 1 from table1 where 书名 = a.书名 and 序号 > a.序号 )
用得着这么麻烦么,select 序号,书名,max(阅读时间) from table1 group by 序号,书名 这样写有什么问题么?
from table1 as a inner join (
select 书名,max(阅读时间) as 阅读时间
from table1 group by 书名) as b
on a.书名=b.书名 and a.阅读时间=b.阅读时间
from table
where 书名,阅读时间
in(
select 书名,max(阅读时间) from table1 group by 书名
)
FROM TATLE1
GROUP BY 书名
select distinct bookname from table order by bookname desc;
from table1 a
where not exists (select 1
from table1
where 书名 = a.书名
and 阅读时间 < a.阅读时间
)
select *
from table1 a
where not exists (select 1
from table1
where 书名 = a.书名
and 序号 < a.序号
)
playyuer(退休干部 卧鼠藏虫)select 1 到底有啥作用,好象得到的全是1的记录
from table1 a
where not exists (select 1
from table1
where 书名 = a.书名
and 阅读时间 < a.阅读时间
)
order by a.序号
select *
from table1 a
where not exists (select 1
from table1
where 书名 = a.书名
and 阅读时间 > a.阅读时间
)
select *
from table1 a
where not exists (select 1
from table1
where 书名 = a.书名
and 序号 > a.序号
)
这样写有什么问题么?