Ⅰ sql查询字段数量
select COUNT(a.name) from sys.all_columns a,sys.tables b
where a.object_id=b.object_id and b.name='table_name'
Ⅱ sql 查询怎么统计多个字段各自的个数
--所有算的地方都用cast(个数asint)
createtabletest05
(avarchar(10),
bvarchar(10),
cvarchar(10))
insertintotest05select'#','一','三'unionall
select'@','一','三'unionall
select'¥','一','二'unionall
select'%','二','二'
select*fromtest05
selectb,COUNT(b)个数fromtest05groupbyb
selectc,COUNT(c)个数fromtest05groupbyc
selectSUM(isnull(t1.个数,0)+isnull(t2.个数,0))总数,sum(isnull(t1.个数,0))个数,t1.b,sum(isnull(t2.个数,0))个数,t2.cfrom
(selectb,COUNT(b)个数fromtest05groupbyb)ast1fulljoin
(selectc,COUNT(c)个数fromtest05groupbyc)ast2ont1.b=t2.c
groupbyt1.b,t2.c
Ⅲ 怎么通过一个sql语句查询一个表中字段的个数
select
a.name
,count(0)字段总数
from
sys.objectsa
innerjoinsys.all_columnsbona.object_id=b.object_id
where
a.type='U'anda.name='表名'
groupby
a.name
修改逗表名地为实际需要查询的表名即可
Ⅳ SQL 统计字段值的数量
用分组,组内计数就可以了,意思就是根据字段a的取值进行分组,相同的为一组,在用count进行组内计数select
a,count(*)from
agroup
by
a
Ⅳ sql 查询某一字段值的个数
select字段1,count(字段2)个数
fromtabname
groupby字段1
Ⅵ sql语句统计数量 统计一个字段出现的数量
1、创建测试表,
create table test_stu(id number, u_name varchar2(20), subject varchar2(20));
create table test_subj(id number, subject varchar2(20));
Ⅶ 如何统计SQL中某字段总数和符合某条件的数量
输入代码
select 名称
,count(*) as 总数量
,count(case when 类型='A' then 类型 else null end) as 类型为A的数
from 表名
group by 名称。
就可以统计SQL中某字段总数和符合某条件的数量。
Ⅷ sql 查询 不同字段的数量
请参考下列sql语句:
select
(select count(*) from tblName
where type=100) as QtyAt100,
(select count(*) from tblName
where type=101) as qtyAt101;
或者
select
sum(case type when 100 then 1 else 0 end) as QtyAt100,
sum(case type when 101 then 1 else 0 end) as QtyAt101 from tblName
where type=100 or type=101;
Ⅸ sql 如何查询字段的个数
set rs=server.createobject("adodb.recordset")sql="select * from 表名"rs.open sql,conn,1,1'开始赋值FieldCount=rs.fields.count