• 主页
• 基础类
• 应用实例
• 新技术前沿

# 找出不同的记录

hongyuan20022003 2007-12-14 05:43:13

s e aa bb cc
0 1 3 4 6
2 4 6 6 4
............

s\e\aa\bb\cc均为正整数，

select distinct s,e,aa,bb,cc from hh

select distinct s,e,aa,bb,cc from gg

select distinct s,e,aa,bb from hh

select distinct s,e,aa,bb from gg

...全文
55 点赞 收藏 6

6 条回复

Moose 2007-12-15
select hh.*
from hh
left join gg
on gg.cc=hh.cc
and gg.s=hh.s
and gg.e=hh.e
and gg.aa=hh.aa
and gg.bb=hh.bb
where gg.cc is null

``````select distinct s,e,aa,bb,cc from hh where checksum(s,e,aa,bb,cc) not int (select checksum(s,e,aa,bb,cc) from gg)

select distinct s,e,aa,bb from hh where checksum(s,e,aa,bb) not in(select checksum(s,e,aa,bb) from gg)

select
distinct s,e,aa,bb,cc
from
hh
where
not exists (select 1 from gg where s=hh.s and e=hh.e and  aa=hh.aa and bb=hh.bb and cc=hh.cc)

select
distinct s,e,aa,bb,cc
from
hh
where
not exists (select 1 from gg where s=hh.s and e=hh.e and  aa=hh.aa and bb=hh.bb)
``````

zheninchangjiang 2007-12-14
select distinct s,e,aa,bb from hh

select distinct s,e,aa,bb from gg

select * from hh a where not exists(select 1 from gg where s=a.s and e=a.e and aa=a.aa and bb=a.bb and cc=a.cc)

``````select * from hh where checksum(s,e,aa,bb,cc) not in(select checksum(s,e,aa,bb,cc) from gg)

select * from hh where checksum(s,e,aa,bb) not in(select checksum(s,e,aa,bb) from gg)``````

hongyuan20022003 2007-12-14
cc的范围是-1/0/1

Moose 2007-12-14
select hh.*
from hh
left join gg on gg.cc = hh.cc
where gg.cc is null

MS-SQL Server

3.2w+

MS-SQL Server相关内容讨论专区