select coalA as coal0 ,count(coalB) as coal1,count(colC) as col2 From (select t1.coalA as coalA,t1.coalB as coalB,t2.coalC as coalC from t1,t2 where t1.coalA = t2.coalA) temp group by temp.coalA
select T1.ColA As Col0, Count(T1.ColB) AS Col1, Count(T2.Colc) AS Col2 From T1,T2 where t1.colA = t2.colA Group by T1.ColA
select T1.ColA,count(distinct T1.ColC),count(distinct T2.ColC) from T1 join T2 on T1.ColA=T2.ColA group by T1.ColA 这只限于T1.ColA的元素集合等于T2.ColA的元素集合的情况。否则还要加上右连接。
你试试select count(字段) from db group by 字段 havine 条件 如果条件太过繁琐!推荐你用table, table.first while not table.eof do begin if table.fieldbyname(';;;')=你的各种条件 then count:=count+1; table.next; end; 然后对一行行的数据,进行判断!这样比较好! 而且速度也不见的慢多少!
(select t1.coalA as coalA,t1.coalB as coalB,t2.coalC as coalC from t1,t2 where
t1.coalA = t2.coalA) temp
group by temp.coalA
这只限于T1.ColA的元素集合等于T2.ColA的元素集合的情况。否则还要加上右连接。
而是根据本表中的其他字段确定的条件(不涉及其他表)来Count。我SQL语句不大熟,请各位多多帮忙了。
如果条件太过繁琐!推荐你用table,
table.first
while not table.eof do
begin
if table.fieldbyname(';;;')=你的各种条件 then
count:=count+1;
table.next;
end;
然后对一行行的数据,进行判断!这样比较好!
而且速度也不见的慢多少!