如何对同一个表的两个字段同时分组??
希望结果集是:table.a,count(table.b),count(table.c)三个字段,请问SQL语句怎么写??
请高手帮忙!!!
希望结果集是:table.a,count(table.b),count(table.c)三个字段,请问SQL语句怎么写??
请高手帮忙!!!
解决方案 »
- fastreport 4.28导出PDF加密的问题
- 问一个不着边际的问题,关于球运行的轨迹与力学,有兴趣请看
- 如何用函数地址或函数指针调用自定义的一个函数?
- 请问如何用鼠标滚轮来放大或缩小图片的大小?如何入手呢?
- excelworksheet中的第二行的单元格已设置为自动换行,如何让第二行的单元格自动调整行的高度,来显示多行内容?
- MDI的问题,在线等,立即给分
- 请问在ACCESS中做的报表,在DELPHI中可以调用吗
- 只运行一个MDICHILD窗口
- access与sql server的日期问题(特急,请高手一定看一下,分不是问题)
- 用DELPHI 编写WEB ISAPI
- 按时间查询的问题
- delphi打包问题
from table
group by table.a有什么问题吗?
from a,b,c
where a.a=b.a and a.a=c.a
联接字段
a b c
001 1001 t
001 1002 f
002 1003
002 1004 t
002 1005 t
003 1006
想table.a,count(table.b),count(table.c),统计出c中不为空的记录数
table如:
a b c
001 1001 t
001 1002 f
002 1003
002 1004 t
002 1005 t
003 1006 希望结果集是:table.a,count(table.b),count(table.c<>'')三个字段,
请问SQL语句怎么写??这次问题说清楚了吧?请高手帮忙!!!
希望结果集是:
001 2 2
002 3 2
003 1 0 请给出完整SQL语句!!!!!!
(selec a ,count(b) from table group by a ) as table1
(selec a, count(c) from table group by a where not c is null) as table2
where table1.a = table2.a
001 2 2
002 2 2
003 0 0
刚试了。
郁闷
from table
where c =''
select a,count(b) as c1,count(c) as c2
from table
where c <>''
(selec a ,count(b) from table group by a ) as table1
(selec a, count(c) from table group by a where not c is null) as table2
where table1.a = table2.a结果为:
001 2 2
002 3 2003就没有了
HAING c is not null
SELECT a,count(b),count(c) FROM table GROUP BY a
HAING c is not null服务器: 消息 8121,级别 16,状态 1,行 11
列 'table.c' 在 HAVING 子句中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
(select zchdpc as hdpc,count(zcbh) as zcs from zchdjd group by zchdpc) a
left join zchdjd b
on b.zchdpc =a.hdpc and b.hdbz <> '' group by a.hdpc,a.zcs
From (Select a,b,Case When c is null then 0 else 1 end From Table) aaa
group by aaa.a
From (Select a,b,Case When c is null then 0 else 1 end c From Table) aaa
Group by aaa.a
的方法不错,挺简洁!!!