编号 名称 规格 明细
001 002 003 1
001 002 003 1
004 005 006 2
004 005 006 2
004 005 006 2结果编号 名称 规格 明细
001 002 003 1
1
004 005 006 2
2
2
001 002 003 1
001 002 003 1
004 005 006 2
004 005 006 2
004 005 006 2结果编号 名称 规格 明细
001 002 003 1
1
004 005 006 2
2
2
解决方案 »
- SQl server manager studio windows 身份验证和sql身份验证都连接不上了怎办
- 辅助文件的删除
- 排序问题 (怪问题)
- 如何清空数据库的所有数据?
- 请教。SQLSERVER2000中如何打开查询一个SYbase anywhere 中的一个表。
- 请问:在一个 sql 语句中,能否对 2 个字段 (或多个字段) 进行 group by ?
- slq server2008 ip连接问题
- *********好着急!!只8000多条记录查询怎么也会出现超时??*********
- 求救:如何让MSDE2000 安装结束后不重新启动机器啊
- 在VB.NET中引用SQLDMO获取局域网SQL服务器名称时出现错误,为什么?
- 为什么我对以前建的表进行修改,甚至是修改人名都会出错?等
- 请教,两种连接方式的区别
select
编号=case when a.id =b.id then a.编号 else '' end,
名称=case when a.id =b.id then a.名称 else '' end,
规格=case when a.id =b.id then a.规格 else '' end,
a.明细
from # a, (
select id=min(id),编号,名称,规格 from #
group by 编号,名称,规格
)b
where a.编号=b.编号 and a.名称=b.名称 and a.规格=b.规格drop table #
select id=identity(int,1,1) * into # from 你的表
order by 编号,名称,规格
select
编号=case when a.id =b.id then a.编号 else '' end,
名称=case when a.id =b.id then a.名称 else '' end,
规格=case when a.id =b.id then a.规格 else '' end,
a.明细
from # a, (
select id=min(id),编号,名称,规格 from #
group by 编号,名称,规格
)b
where a.编号=b.编号 and a.名称=b.名称 and a.规格=b.规格
order by a.id -- 保证顺序
drop table #