sql server 一对多统计数量

[复制链接]
查看11 | 回复2 | 2013-8-22 11:32:25 | 显示全部楼层 |阅读模式
数据我这里叫a,b,c了,跟你表1,2,3是对应的create table a(uid int,name varchar(10))insert into a values (1,'张一')insert into a values (2,'张二')create table b (uid int,type1 varchar(1))insert into b values (1,'a')insert into b values (1,'b')insert into b values (1,'c')insert int...
回复

使用道具 举报

千问 | 2013-8-22 11:32:25 | 显示全部楼层
--楼主这个分组就可以了--有什么问题可以随时找我 希望采纳select tb2.uid,count(distinct type1) type1,count(distinct type2) type2from tb1 join tb2 on tb1.id=tb2.uidjoin tb3 on tb1.id=tb3.uidgroup by ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行