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 [Store_Abbreviation] ,[Goodname], [Goodmodel] ,SUM(Order_Quantity) AS Order_Quantity, [Workid]from [fangtaidata].[dbo].[SalesStatistics]...

sql可以使用not like 查询字段不以某个特殊字段开头的所有记录 LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式。 select * from table where value not like '0%' and value not like 'A%';

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

这样可以查出colA,colB字段没有重复的记录: select * from 表 a where not exists(Select 1 from 表 where colA=a.colA and colB=a.colB) 像你说的如果distinct A,B然后再加上其他 字段,这样本来说法是没有意思的。因为a,b的组合对就的可能是...

可用group by……having来实现。 可做如下测试: 1、创建表插入数据: create table test(id int,name varchar(10))insert into test values (1,'张三')insert into test values (2,'李四')insert into test values (3,'张三')insert into test va...

查看可用如下方法: 1、创建测试表,插入数据: create table product(id int,name varchar(10),totol int)insert into product values (1,'香蕉',100)insert into product values (2,'橘子',67)insert into product values (3,'葡萄',89)insert...

创建测试表 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 ('王五'...

网站地图

All rights reserved Powered by www.1862.net

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