读书人

一个临时表的小有关问题

发布时间: 2011-12-24 23:03:24 作者: rapoo

一个临时表的小问题
select top 5 h.Qu as '数据内容 ' ,count(d.HouseID) as '成交数量 ' from Houses h
inner join Deals d on h.HouseID = d.HouseID
where h.houseID in (select HouseID from Houses) and
convert(nvarchar(2) , d.CheckTime , 101) = @time
Group by h.Qu order by Count(d.HouseID) desc

数据内容 成交数量
------ -----------
闵行区 27
长宁区 10
浦东新区 7
松江区 6
虹口区 4


create table #table1
(
区域 nchar(4),
成交数 int,
月份 int
)
我要把上面查出来的值放到一个临时表??怎么做啊??

[解决办法]
declare @temp table(域 nvarchar(15),成交量 int 月份 int)

insert into @temp select top 5 h.Qu as '数据内容 ' ,count(d.HouseID) as '成交量 'from Houses h
inner join Deals d on h.HouseID = d.HouseID
where h.houseID in (select HouseID from Houses) and
convert(nvarchar(2) , d.CheckTime , 101) = @time
Group by h.Qu order by Count(d.HouseID) desc

不多,就用table量

读书人网 >asp.net

热点推荐