50求一SQL语句,正解即结贴!
news表
cid(文本) ctitle bigclassID infotime
20060406100018 asdf 20060315100001 2006-5-6 14:54:57
20060406100019 qwer 20060315100002 2006-6-6 14:54:57
20060406100020 awer 20060315100002 2006-6-814:54:57
20060406100021 sdf 20060315100003 2006-7-6 14:54:57
20060406100022 12asdf 20060315100001 2007-5-6 14:54:57
20060406100023 3qwer 20060315100002 2007-6-6 14:54:57
20060406100024 4awer 20060315100004 2007-7-6 14:54:57
20060406100025 4sdf 20060315100003 2007-8-6 14:54:57
bigclass表
bigclassID name
20060315100001 a
20060315100002 b
20060315100003 c
20060315100004 d
查询出每类新闻的cid值最大的两条记录.也就是每类新闻最新的两条数据.大家帮忙.
------解决方案--------------------SELECT *
FROM News as A
where cid in (select top 2 cid from News where bigclassID=A.bigclassID order by cid desc)