求一个sql语句

yx360 2005-11-14 02:55:52
表table如下:

serial user
A-1 lin
A-1 mary
A-2 lin
A-2 mary
A-3 lin
A-5 mary
A-1 lin

我想统计出用户lin每种型号的数量,比如A-1一共有多少、A-2有多少……请问这个sql语句该怎么写~
...全文
110 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzhuyy 2005-11-14
  • 打赏
  • 举报
回复
select serial,count(serial)as tj from TestTB where uer='lin' group by serial

OK
slayerbb 2005-11-14
  • 打赏
  • 举报
回复
理解错误。。
==
yx360 2005-11-14
  • 打赏
  • 举报
回复
结果应该是

lin A-1 3
A-2 2

类似这样的~~
tigerwen01 2005-11-14
  • 打赏
  • 举报
回复
select serial,count(serial)as tj from TestTB where uer='lin' group by serial
yx360 2005-11-14
  • 打赏
  • 举报
回复
1楼的是所有lin用户的产品总和~不是我要的
2楼和3楼的方法~~要是我有100种产品~那不是要写100个sql语句了~~

求助求助~~
pzhuyy 2005-11-14
  • 打赏
  • 举报
回复
如上结果类似于
A-1 2
A-2 1
A-3 1
pzhuyy 2005-11-14
  • 打赏
  • 举报
回复
楼主的意思是用一句SQL实现所有型号的数量,又不只是A-1的
bigluckyfox 2005-11-14
  • 打赏
  • 举报
回复
select count(serial) from table where user=lin and serial=A-1

skycuilin 2005-11-14
  • 打赏
  • 举报
回复
set rs=create.object("adodb.recordset")
sql="select * from tabel where serial='A-1' and user='lin'"
rs.open sql,conn,1,1
x=rs.recordcount
实际上rs.recordcount就是计算你的记录总数
slayerbb 2005-11-14
  • 打赏
  • 举报
回复
select sum(t.serial) as serialsum from table t where t.user='lin'

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧