请用一句话在SQL Server 2000中完成
解决方案 »
- 怎样判断SQL和ACCESS中,哪一列是自动增加列!
- 菜鸟请教一个问题
- 還原拿回來的數據庫時候出錯
- mssql 的日志文件太大了 怎么办?
- 如何取函数值的小数点后2位
- 一个数据库只有一个mdf,那我的怎么可以有多个mdf?建2个文件组怎么可以分别有mdf?
- 关于sqlserver的外键
- update b set b.col1=a.col1 and b.col2=a.col2 where a.key=b.key and a.col1<>b.col2
- sql server 2000 兼容性&速度问题
- 从一个表里进行查询,查询结果有多条记录,如何我只想要其中的某一条,请问如何取出。
- 在我的触发器中,为什么字符串连接没有生效啊?
- 简单问题
from table AA
group by isnull(fromcomno,endcomno),isnull(fromtype,endtype)
一个表可以有多个主键
??
fromComNo fromType fromTime theGoods endComNo endType endTime
和黄 #1 8:00 99807 友利 #2 9:00
友利 #2 10:00 77809 港灯 #1 11:00
港灯 #1 8:00 55608 和黄 #2 8:30
香港电信 #1 7:00 87692 和黄 #1 11:00统计结果应该如下:
和黄 #1 2
和黄 #2 1
友利 #2 2
港灯 #1 2
香港电信 #1 1
insert into #temp select endcomno,endtype from tableselect comno,type,(select count(*) from #temp where comno=AA.comNO and type =AA.type) as Rec_count from #temp AA group by comNo,Type
select comno,type,count(*) as Rec_count from
(select fromComNo as comno,fromType as type from table
union all
select endcomno,endtype from table
)AA group by comNo,Type
select aa 别名1,bb 别名2,count(*) 别名 from
(select fromComNo aa,fromType bb from table
union all
select endcomno aa,endtype bb from table
)AA group by 别名1,别名2
select ComNo, Type, Count(*) from
(select fromComNo as ComNo, fromType as Type from 表
union all
select endComNo endType from 表) as vTemp
group by ComNo, Type
union all
select endComNo as ComNo, endType as Types, endTime as Time, theGoods from table) agroup by a.types
from table
group by fromComNo, fromTypeunion allselect endComNo as ComNo, endType as Types, count(*)
from table
group by endComNo, endType