--测试环境
declare @t table(bookid int,type varchar(5))
insert into @t select 1,'''A'''
union all select 2,'''A'''
union all select 3,'''B'''
union all select 4,'''B'''
union all select 5,'''B'''
--查询SQL
select type,typeCount=count(type)
from @T
group by type
--结果
type typeCount
----- -----------
'A' 2
'B' 3(所影响的行数为 2 行)
declare @t table(bookid int,type varchar(5))
insert into @t select 1,'''A'''
union all select 2,'''A'''
union all select 3,'''B'''
union all select 4,'''B'''
union all select 5,'''B'''
--查询SQL
select type,typeCount=count(type)
from @T
group by type
--结果
type typeCount
----- -----------
'A' 2
'B' 3(所影响的行数为 2 行)
解决方案 »
- sql group by分组排序问题
- 我的数据库myer.mdf谁都可以在企业管理器中打开看,我不知道如何加密它。好像在企业管理器中打开以后,找不到建立用户名和密码的地方,请赐教。我希望只有我能用一个用户名和密码打开,如何做。谢谢!
- 请问dawugui有关sql语句的问题,
- 如何分配序号?请高手快来帮忙
- 请教关于事务处理的代码?急*********
- 判断行之间是否存在重
- 今天的一道面试题
- 请问一下在SQL中出现的错误
- 我的数据库里有120个表,我想知道每个表的记录数是多少,用数据库里的哪个系统存储过程,在线等候......
- 在SQL SERVER里能不能存储JPG类型的图片!!!
- 大型项目规划的问题
- 获取各类别下前3条产品信息,请达人帮助优化!致谢!
from 表
group by type