select * from tablename a where id in(select top 2 id from tablename where pid=a.pid order by id desc) order by pid asc,id desc
select * from tablename a where id in(select top 2 id from tablename where pid=a.pid order by id desc) order by pid asc,id desc
select top 4 a.* from 表 a where a.id=(select max(id) from 表 where pid=a.pid) order by a.id desc
select * from 表 a where id in(select top 2 id from 表 where pid=a.pid order by id desc) order by pid,id desc
select * from 表 a where id in(select top 2 id from 表 where pid=a.pid order by id desc) order by pid,id desc
那要是读取不同pid的前2条怎么写?谢谢!~
select top 4 a.* from 表 a where (select count(*) from 表 where pid=a.pid and id<=a.id)<=前几条 order by a.id desc
愁死了!~请问有什么好的复杂sql语句生成工具?
那要是读取不同pid的前2条怎么写?谢谢!~ select * from 表 a where id in(select top 2 min(id) from 表 where pid=a.pid group by pid having count(pid)=1) order by pid,id desc
select * top 4 from a (select id,distinct pid,text from b1) a order by id desc
from tablename a
where id in(select top 2 id from tablename where pid=a.pid order by id desc)
order by pid asc,id desc
from tablename a
where id in(select top 2 id from tablename where pid=a.pid order by id desc)
order by pid asc,id desc
from 表 a
where a.id=(select max(id) from 表 where pid=a.pid)
order by a.id desc
order by pid,id desc
order by pid,id desc
from 表 a
where (select count(*) from 表 where pid=a.pid and id<=a.id)<=前几条
order by a.id desc
select * from 表 a where id in(select top 2 min(id) from 表 where pid=a.pid group by pid having count(pid)=1)
order by pid,id desc
(select id,distinct pid,text from b1) a
order by id desc