重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
试试下面的SQL语句是否符合你的需求: --A:
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了甘谷免费建站欢迎大家使用!
select XX_id
from tiantiantian
where sum_date=20110420
and XX_status 30
and XX_type in (1009, 1008, 1003, 1011)
and XX_date to_date(20110420, 'yyyymmdd')
and not exists(
select xx_id from dididi
where sum_date=20110420
and XX_status 30
and XX_type in (1009, 1008, 1003, 1011)
and XX_date to_date(20110420, 'yyyymmdd'));
--B:
select XX_id
from dididi
where sum_date=20110420
and XX_status 30
and XX_type in (2001)
and XX_date to_date(20110420, 'yyyymmdd')
and not exists(
select xx_id from tiantiantian
where sum_date=20110420
and XX_status 30
and XX_type in (2001)
and XX_date to_date(20110420, 'yyyymmdd'));
1。用rowid方法
据据oracle带的rowid属性,进行判断,是否存在重复,语句如下:
查数据:
select * from table1 a where rowid
!=(select max(rowid)
from table1 b where a.name1=b.name1 and
a.name2=b.name2......)
删数据:
delete from table1 a where rowid
!=(select max(rowid)
from table1 b where a.name1=b.name1 and
a.name2=b.name2......)
2.group by方法
查数据:
select count(num), max(name) from student --列出重复的记录数,并列出他的name属性
group by num
having count(num) 1 --按num分组后找出表中num列重复,即出现次数大于一次
删数据:
delete from student
group by num
having count(num) 1
这样的话就把所有重复的都删除了。
3.用distinct方法 -对于小的表比较有用
create table table_new as select distinct *
from table1 minux
truncate table table1;
insert into table1 select * from table_new;
SELECT DISTINCT TA.QA_TYPE TYPE,
TQ.TYPE_DESCRIPTION TYPEDESCRIPTION
FROM T_QA_RULE_DEFINE TA, T_QA_CHECK TQ
WHERE TA.QA_TYPE = TQ.TYPE
AND TA.QA_CHECK_TYPE = TQ.CHECK_TYPE
AND TA.VALID_FLAG = 'Y'
只取这两个字段不就行了么,是不是你想要的
加distinct,
SELECT distinct sequence_no, channel_id, base_id, product_mode,model_code,rated_voltage, spec, brand_name, show_flag, model_id
FROM table_name
where user_id=1
查出来是没有重复记录的,如果想要model_id 没有重复,还需要做别的条件的限制