【发布时间】:2011-03-22 09:20:56
【问题描述】:
SELECT (select count(u.ag_code)
from table1 as u inner join table2 as tc
on u.industry_id=tc.tempcatid
where u.ag_code!=0) as agnt,
(select count(u.ag_code)
from table1 as u inner join table2 as tc
on u.industry_id=tc.tempcatid where u.ag_code=0),as dircus,
tc.catename from table1 as u inner join table2 as tc
where u.industry_id=tc.tempcatid
group by tc.tempcatid
这个查询有错误
我在一个查询中需要两个计数和类别名称
这是计数的条件
- ag_code!=0
- ag_code=0
在 table1 中有列 ag_code(这有 0 和非零值)
我的结果需要这样
Full Texts
agent customer catename
11 3 Real Estate
15 1 Automobile
3 0 Medical
34 77 Business
1 45 Travel & Hotels
11 3 Construction & Engineering
【问题讨论】:
-
问题是什么?您发布的查询有什么结果?
-
我真的试图专注于您的查询到底在做什么,但我真的无法掌握它。您需要在此处更详细地描述您要完成的工作。