我在写一个asp.net的输出页
2个表以及相关字段是:
Table1: Table2:
id name uid
1 A 1
2 A 2
3 A 3
4 B 4
5 B
6 C
页面上的结果是这样:
name num num1
A 3 3
B 2 1
C 1 0
前两列的输出我是这样写的 select name,count(name) from Table1 group by name order by name;
请问第3列的输出应该怎么写或者怎么加到上边的语句里?
2个表以及相关字段是:
Table1: Table2:
id name uid
1 A 1
2 A 2
3 A 3
4 B 4
5 B
6 C
页面上的结果是这样:
name num num1
A 3 3
B 2 1
C 1 0
前两列的输出我是这样写的 select name,count(name) from Table1 group by name order by name;
请问第3列的输出应该怎么写或者怎么加到上边的语句里?
(
b int
, c varchar(2)
)
insert into #a
select 1,'A'
union all
select 2,'A'
union all
select 3,'A'
union all
select 4,'B'
union all
select 5,'B'
union all
select 6,'C'
create table #b
(
c int
)
insert into #b
select 1
union
select 2
union
select 3
union
select 4select
c
,count(c)
,(select count(1) from #b where c in (select b from #a where t.c=c ))
from
#a t
group by c
order by cdrop table #a,#b
select b from #a where t.c=c from #a t
这句中 t是什么意思?帮忙解释下~
这句中 t是什么意思?帮忙解释下~