972
社区成员




select B from tables where E=2049 and C=true and F between '2010-01-01' and '2015-01-01' group by B
having count(A)>1 and -- 这个地方应该判断区域是否重复
order by A
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。 参考一下这个贴子的提问方式http://bbs.csdn.net/topics/320211382 1. 你的 create table xxx .. 语句 2. 你的 insert into xxx ... 语句 3. 结果是什么样,(并给以简单的算法描述) 4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL) 这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。
create table testtables(
A INTEGER,
B VARCHAR(500) ,
C BOOLEAN,
D INTEGER ,
E INTEGER,
F VARCHAR(100)
)
insert into testtables(1005,'acbfdsa',true ,1 ,2049 ,'2010-04-05 10:00:00');
insert into testtables(1005,'akjfjbg' ,true ,2 ,2049 ,'2013-04-05 10:00:00');
insert into testtables(1005,'adsjhgfvdh' ,true ,2 ,2049 ,'2005-04-05 10:00:00');
insert into testtables(1005,'weuriuzdx' ,true ,1 ,2049 ,'2009-04-05 10:00:00');
insert into testtables(1007,'weiureowpiuoz' ,true ,2 ,2050 ,'2008-04-05 10:00:00');
insert into testtables(1007,'weiouzjkldsaiwe' ,true ,2 ,2050 ,'2007-04-05 10:00:00');
insert into testtables(1007,'dzoiudziouiodsq' ,true ,2 ,2050 ,'2005-04-05 10:00:00');
insert into testtables(1007,'cxziouvoiuoezdf' ,true ,2 ,2050 ,'2001-04-05 10:00:00');
insert into testtables(1037,'cxzm,skljfdaswewscdsafdw' true 1 2050 ,'2006-04-05 10:00:00');
insert into testtables(1037,'ewoiuwqiourewioqxcfaswsadfafw' ,true ,1 ,2050 ,'2012-07-05 10:00:00');
insert into testtables(1037,'weteuwqozoiduioafadsafewtywdfre', true ,1 ,2050 ,'2018-12-05 10:00:00');
插入测试数据可以用上面的sql[手写,未测试...]