去重的按某个字段进行去重sql

delete from op_car_owners2 where carnum in(
 select carnum  from(
  select max(carnum ) as carnum ,count(carnum) as count from op_car_owners2 group by carnum having count>1 order by count desc
 ) as tab
)

DELETE from op_car_owners2 where carnum=‘苏A9CC18‘ and phone=‘0‘

时间: 2024-12-19 09:05:19

去重的按某个字段进行去重sql的相关文章

sql 语句查询 按某字段去重 保留按某个字段排序top1

例子:      建表: create table tablename  (id int identity(1,1),attachid int,name varchar(10)) insert into tablename  values(23,'sss') insert into tablename   values(33,'sdfs') insert into tablename   values(33,'4434') insert into tablename   values(45,'d

SQL Fundamentals SQL列字段的处理 SQL(case、decode、行转列)

列字段的处理 SQL Case 对列做处理 SQL> select deptno,sum(sal) from emp group by deptno; Select case when deptno=10 then 'ACCOUNTING' when deptno=20 then 'RESERCH' when deptno=30 then 'SALES' end, sum(sal) from emp group by deptno 列字段的处理 SQL Decode 还有一种情况是当什么都不是的

MySQL字段联合去重sql

例如数据 id,name1,name2 1 a x 2 a y 3 b x 4 a y 5 a x 联合去重name1,name2的结果为 id,name1,name2 1 a x 2 a y 3 b x 的SQL为 select * from table group by name1,name2;

Flink去重第三弹:HyperLogLog去重

HyperLogLog算法 也就是基数估计统计算法,预估一个集合中不同数据的个数,也就是我们常说的去重统计,在redis中也存在hyperloglog 类型的结构,能够使用12k的内存,允许误差在0.81%的情况下统计2^64个数据,在这种大数据量情况下能够减少存储空间的消耗,但是前提是允许存在一定的误差.关于HyperLogLog算法原理可以参考这篇文章:https://www.jianshu.com/p/55defda6dcd2里面做了详细的介绍,其算法实现在开源java流式计算库strea

触发器实现对插入数据的字段更改 Oracle+SQL Server

最近有个使用触发器实现对插入数据的某个列做更改的需求,因此整理了Oracle和SQL Server对于此类需求的触发器写法,本文仅提到了Insert触发器. 首先我们创建一张表: --创建Test表 Create table test(id int primary key,name varchar(20),sex varchar(1),status int) 我们的目的是实现新插入的数据满足sex字段为null时就把status设为1的需求,可根据实际需要更改条件. 因此SQL Server的写

用SQL语句添加删除修改字段_常用SQL

1.增加字段     alter table docdsp     add dspcodechar(200)2.删除字段     ALTER TABLE table_NAME DROP COLUMNcolumn_NAME3.修改字段类型     ALTER TABLE table_name     ALTER COLUMNcolumn_name new_data_type4.sp_rename 改名     EXEC sp_rename '[dbo].[Table_1].[filedName1]

Sql Server 添加、更新、查询表注释、字段注释相关sql

/*******************字段添加注释*********************/ if not exists (SELECT C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id INNER JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_

数据库高并发情况下重复值写入的避免 字段组合约束+ SQL SERVER 的SQL语句优化方式小结(转)

10线程同时操作,频繁出现插入同样数据的问题.虽然在插入数据的时候使用了: insert inti tablename(fields....) select @t1,@t2,@t3 from tablename where not exists (select id from tablename where [email protected],[email protected],[email protected]) 当时还是在高并发的情况下无效.此语句也包含在存储过程中.(之前也尝试线判断有无记

SQL查询表,表的所有字段名,SQL查询表,表的所有字段名

SQL查询表,表的所有字段名 2011-07-29 10:21:43|  分类: SQLServer |  标签:表  sql  字段   |举报 |字号 订阅 SQL查询表,表的所有字段名 SQL SERVER 查看所有表名: select name from sysobjects where type='U' 查询表的所有字段名: Select name from syscolumns Where ID=OBJECT_ID('表名') select * from information_sc