select * as table2 from table1 group by aa.c1 select * as table3 from table2 group by aa.c2 table3就是你想要的结果,没测试过,试试~~~
既然是BDE,完全可以新建一个表,然后加入记录
create table tablename1 as select * from aa group by c1 create table tablename2 as select * from tablename1 group by c2 tablename2里就是你要的内容 用好后,drop table tablename1 和 tablename2 就行了。
一行搞定: delete from aa.db where aa.c1+aa.c2 not in (select aa.c1+min(aa.c2) group by aa.c1) 以上语句是在c2为字符型的条件下写出的.如果不是字符,首先转换一下就行了.
我在SQL server里面试过了.我的方法是可行的. select aa.c1+min(aa.c2) group by aa.c1 得到的结果是111 222 和 555 666 之所以在你的数据库中不成功是因为没有转换类型.我不知道parodox中有没有将长整型数据转化为字符型的没有,反正在其它的dbms里面应该是有的. 比如: delete from aa.db where str(aa.c1)+str(aa.c2) not in (select str(aa.c1)+str(min(aa.c2)) group by aa.c1)
试试select a.* from aa a, (select c1,min(c2) from aa group by c1) b where a.c1 = b.c1 and a.c2 = b.c2
with query2 do begin close; sql.clear; sql.add('select distinct c2 from aa newTable where c1 in (select disinct c1 from newTable ) ); open; end;
select * as table3 from table2 group by aa.c2
table3就是你想要的结果,没测试过,试试~~~
as select * from aa group by c1
create table tablename2
as select * from tablename1 group by c2
tablename2里就是你要的内容
用好后,drop table tablename1 和 tablename2 就行了。
delete from aa.db where aa.c1+aa.c2 not in (select aa.c1+min(aa.c2) group by aa.c1)
以上语句是在c2为字符型的条件下写出的.如果不是字符,首先转换一下就行了.
select aa.c1+min(aa.c2) group by aa.c1
得到的结果是111 222 和 555 666
之所以在你的数据库中不成功是因为没有转换类型.我不知道parodox中有没有将长整型数据转化为字符型的没有,反正在其它的dbms里面应该是有的.
比如:
delete from aa.db where str(aa.c1)+str(aa.c2) not in (select str(aa.c1)+str(min(aa.c2)) group by aa.c1)
aa a, (select c1,min(c2) from aa group by c1) b
where a.c1 = b.c1 and a.c2 = b.c2
with query2 do
begin
close;
sql.clear;
sql.add('select distinct c2 from aa newTable where c1 in (select disinct c1 from newTable ) );
open;
end;
而且,sql也可以进行对重嵌套