xkzy.net
当前位置:首页 >> sql查询 次数 >>

sql查询 次数

我觉得好像不用楼上那么复杂吧? 1 select count(*) from (select distinct 列名 from 表名) 子查询中使用distinct查询出所有不同的值,然后用select count(*)查询子查询返回到行数。

select Name as '姓名', count(base) as '咨询次数' from A inner join B on A.a = B.b where Date between '2015-06-15 00:00:00' and '2015-06-21 23:59:59' and qykf='签约客户' and Name in ('李雷','韩梅梅') group by Name order by Name;

select count(name) ,name from table group by name having count(name)>1

select top 1 pid, count(pid) as [pidcount] from 表名 group by pid order by pidcount desc 如果只要pid,可以 select pid from (select top 1 pid, count(pid) as [pidcount] from 表名 group by pid order by pidcount desc) as a

select B, count(*) -- 计算个数,速度快于count(字段). 因为 count(字段)会先判断这个字段是否为空,只计算非空的个数。所以这里直接用count(*)。 from A group by B

SELECT 某列, COUNT(*) FROM 某表 GROUP BY 某列 ORDER BY COUNT(*)

select a.duiwu ,a.胜,b.负 from (select count(*) 胜, duiwu from tabb where shengfu='胜' group by duiwu ) a left join (select count(*) 负, duiwu from tabb where shengfu='负' group by duiwu ) b on a.duiwu=b.duiwu --sql2000调试通过...

特别推荐: select xingming , count(*) from biao group by xingming having count(*) > 2

比如我有一个aaa 表,字段为payed ,其中有两个关键字 ‘1’ 和 ‘2’ 查出数据为2列的话: select (select COUNT(payed) from aaa where payed like '%1%') as a,(select COUNT(payed) from aaa where payed like '%0%') as b 查出数据为1列的话: ...

select 字段,count(*) from 表明 group by 字段

网站首页 | 网站地图
All rights reserved Powered by www.xkzy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com