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

iamwho iamwho 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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语句或者是存储过程写出来,谢谢各位!!!!
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
iamwho
MS-SQL Server 34,876 成员 254,635 内容