日期:2014-05-17 浏览次数:20621 次
select ROW_NUMBER() OVER (order by ScanTime) RowNumber,ScanTime,[CSI-10-01-N],[VAD-05-02-B]
from
(
select COUNT(*) total,convert(varchar(100),ScanTime, 23) ScanTime,LocationCode
from WLRS_Tallydata where LocationCode in ('CSI-10-01-N','VAD-05-02-B')
group by LocationCode,convert(varchar(100),ScanTime, 23)
) p
pivot
(
max(total) for LocationCode in ([CSI-10-01-N],[VAD-05-02-B])
)
as X
if object_id('tempdb..#t') is not null
drop table #t
create table #t
(
id int,
。。。。。
)
insert into #t select * from (
if object_id('tempdb..#t') is not null
drop table #t
select * into #t from (...) t