如:表A,
a b c d
ems1 1 2 2
ems1 1 3 3
ems1 2 4 6
ems1 3 A H
ems1 2 4 3
ems1 4 B 2查询表A,要求列出所有的列.执行2次查询,第1次是b列的数据不出现重复的;第2次是b列,d列的数据都不出现重复的.
请给出脚本,谢谢!!!
a b c d
ems1 1 2 2
ems1 1 3 3
ems1 2 4 6
ems1 3 A H
ems1 2 4 3
ems1 4 B 2查询表A,要求列出所有的列.执行2次查询,第1次是b列的数据不出现重复的;第2次是b列,d列的数据都不出现重复的.
请给出脚本,谢谢!!!
解决方案 »
- 求个月份报表
- 用存储过程实现
- 急求,关于一条分组group by 的语句
- 如何搜索某个字符串在N个表的那个字段中,并一次性修改N个表中这个搜索到的字段的所有记录
- SQL SERVER 2000安装后的问题
- 一个罕见的SQLSERVER安装的问题,邀请高手相商!!
- 数据库变成7G,但真正存的数据只有1G多,那位高手帮忙下
- 数据存贮问题?
- 嵌套查询中 如何获得子查询中某字段
- 为什么我把"01-09-17"插入到SQL Server的一日期型字段中,在SQL Server中显示"01-09-2017"?我是用insert语句写的,我该咋办?加分!!?
- 数据加密的方法
- 怎样将一个表中的某个字段默认值改成可改变的?请帮忙~~~
where not exists (
select b from
where a2.b=a1.b
group by b
having count(*)=1
)
select * from a a1
where not exists (
select b,d from
where a2.b=a1.b
and a2.d=a1.d
group by b,d
having count(*)=1
)
where not exists (
select b from
where a2.b=a1.b
group by b
having count(*)>1
)
select * from a a1
where not exists (
select b,d from
where a2.b=a1.b
and a2.d=a1.d
group by b,d
having count(*)>1
)
(select b from A group by b having count(b)=1);select * from A where b in
(select b from A group by b having count(*)=1) and d in
(select d from A group by d having count(*)=1);
select a ,b, c ,d from A where A.ID in (select min(ID)ID from A group by b)
select a ,b, c ,d from A where A.ID in (select min(ID)ID from A group by b,d)
alter table A drop coulumn ID
Yang_(扬帆破浪) ( ) 信誉:132 2006-04-18 17:58:00 得分: 0
错了,改下select * from a a1
where not exists (
select b from a a2 --加表a别名a2
where a2.b=a1.b
group by b
having count(*)>1
)
select * from a a1
where not exists (
select b,d from a a2 --加表a别名a2
where a2.b=a1.b
and a2.d=a1.d
group by b,d
having count(*)>1
)