www.1862.net > SQL 查询表中某一字段不重复的所有数据

SQL 查询表中某一字段不重复的所有数据

SELECT * FROM tablea WHERE (number NOT IN (SELECT ta.number FROM tablea AS ta INNER JOIN tablea AS tb ON ta.number = tb.number AND ta.id tb.id))

可以参考使用如下写法 如果要全部数据则可以 select * from table T1 where 字段 = (select max(字段) from table T2 where T1.字段2 = T2.字段2) 或 select * from table T1 where not exists(select * from table T2 where T1.字段2 = T2.字...

select * from tabnamewhere colname in (select colnamefrom tabnamegroup by colnamehaving count(1) = 1)

select * from tb where parent_id not in( select t1.id from tb t1 join tb t2 on t1.id = t2.parent_id )

友善的提醒两点,如有帮助还望采纳,谢谢! 第一、你这个语句本身写的有点麻烦,简化如下 SELECT [Store_Abbreviation] ,[Goodname], [Goodmodel] ,SUM(Order_Quantity) AS Order_Quantity, [Workid]from [fangtaidata].[dbo].[SalesStatistics]...

创建测试表 create table t(a varchar(10),b int,c varchar(1))insert into t values ('张三',1,'Y')insert into t values ('张三',2,'Y')insert into t values ('张三',3,'N')insert into t values ('李四',1,'Y')insert into t values ('王五'...

依楼上的事例: DELETE FROM 表B WHERE C not in (SELECT C FROM A)

比如重复字段是 A 表 的 name 字段 select name from A group by name having count(name)>1 显示的就是 重复数 大于 1 的 name了 如果你要查看重复的数据 外面就加个 in name select * from A where name in( select name from A group by name...

这个查找过程分两步走: 1、找出这列中有相同内容的记录。代码如下: select 列名 from 表名 group by 列名 having count(列名) > 1 2、把这些有相同内容的记录,查出来。代码如下: select 列名 from 表名 where 列名 in (select 列名 from 表...

查询一个表中某两个字段的相同数据代码是:Select Name,ID From A group by Name,ID having count (*)>1。 结构化查询语言(Structured Query Language)简称SQL,结构化查询语言是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管...

网站地图

All rights reserved Powered by www.1862.net

copyright ©right 2010-2021。
www.1862.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com