关于sql语句查询的问题,如下: 表table,字段(objid,type,date) 查询结果按date倒序,假设数据信息

2025-12-17 17:57:38
推荐回答(3个)
回答1:

我想到一个办法,当然不能算最好的;
建立一个临时表,表结构与原表相同。
然后,根据
Select * From 表 Where type =2 Order By desc
获得返回的记录集,在该记录集里,复制第1条记录到临时表里,从第2条开始判断日期是否与前连续,连续的复制,不连续的结束。
最后,显示临时表里的所有记录。

回答2:

select * from table where type=2 and objid<(select max(objid) from table where type<>2) order by date desc

回答3:

select objid,type,date from table where type=2 order by date desc