sql语句:如何查数据库一个表中的一个行的不同项

2022-11-03 09:02

3个回答
select
max(case t.item1 when 'aa' then count(t.item1) else 0 end) aa,
max(case t.item1 when 'bb' then count(t.item1) else 0 end) bb,
max(case t.item1 when 'cc' then count(t.item1) else 0 end) cc
from 表1 t

group by t.item1
select t.item1, count(*) from 表1 t
group by t.item1
select count(distinct ITEM1) from 表1
就能得出个数啦。
相关问答
SQL数据库无法启动
1个回答2022-09-27 23:30
重新安装数据库!
SQL数据库编程
1个回答2024-06-12 12:03
while 平均分80 then 1 when 平均分70 then 2 when 平均分60 then 3 when 平均分<60 then 5) end
SQL数据库编程
1个回答2024-06-11 16:46
while 平均分80 then 1 when 平均分70 then 2 when 平均分60 then 3 when 平均分<60 then 5) end
怎样用SQL语句查询一个数据库中的所有表
1个回答2022-08-26 05:43
--读取库中的所有表名 select name from sysobjects where xtype='u' --读取指定表的所有列名 select name from syscolumns whe...
全文
sql数据库查询出来的数据从大到小排序
4个回答2022-09-11 08:02
利用order by进行排序,降序(从大到写)可以用desc,升序(从小到大)是默认的
sql数据库查询中,空值查询条件怎么写?
3个回答2023-03-13 10:45
在MS SQL Server和Oracle这两个主要的数据库中,空值都比较特殊,不能直接用"="或"<>"号来比较,如果你要用这两个符号比较,就会发现,空值即不在等于的集内,也不在不等于的集内。 ...
全文
什么是SQL数据库空间?
2个回答2022-07-23 19:22
数据库存储数据时使用的文件占用的空间。。。
sql 2000 进不了数据库
1个回答2022-10-02 14:05
如果能打开master而其它的打开失败的话,那可能是你数据库的问题,检查你的数据库文件是不是被破坏掉了 如果根本连接不上服务器的话,可能是你的注册信息有问题,比如更改了windows密码就需要...
全文
有关sql server数据库设计的问题
1个回答2023-01-21 03:15
用关键字查询,统计
sql数据库入门
3个回答2022-05-20 10:56
这个是一本全面介绍Sql语言的书: 这个是对Sql Server 2005的一本较为全面的介绍书籍,其中涉及到企业级开发和应用的篇章: 希望对你有帮助!
热门问答