我不知道应该用什么标题,是sql语句的问题

iamwho 2004-03-03 09:59:09
select top 2 * from Unit where cid = '100110001000'
union
select top 2 * from Unit where cid = '100110001001'
union
select top 2 * from Unit where cid = '100110001002'
union
select top 2 * from Unit where cid = '100110001003'

大概的意思由上述的语句表达出来了,字段cid在unit表中,就是要在表unit中只选择每个相同cid的前两条记录,但是上述语句无法应对cid变化的情况,我不知道能不能用一个sql语句或者是存储过程写出来,谢谢各位!!!!
...全文
32 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧