Nov 16, 2006
the sql of create table is below:
CREATE TABLE [dbo].[Examp] (
[LocalNetID] [int] NOT NULL ,
[BSCID] [int] NOT NULL ,
[SiteID] [int] NOT NULL ,
[CellID] [int] NOT NULL ,
[StrTime] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[M1] [int] NULL ,
[M2] [int] NULL ,
[M3] [int] NULL ,
[M4] [int] NULL ,
[M5] [int] NULL ,
[M6] [int] NULL ,
[M7] [int] NULL ,
[M8] [int] NULL ,
[M9] [int] NULL ,
[M10] [int] NULL ,
[M11] [int] NULL ,
[M12] [int] NULL ,
[M13] [int] NULL ,
[M14] [int] NULL ,
[M15] [int] NULL ,
[M16] [int] NULL ,
[M17] [int] NULL ,
[M18] [int] NULL ,
[M19] [int] NULL ,
[M20] [int] NULL ,
[M21] [int] NULL ,
[M22] [int] NULL ,
[M23] [int] NULL ,
[M24] [int] NULL ,
[M25] [int] NULL ,
[M26] [int] NULL ,
[M27] [int] NULL ,
[M28] [int] NULL ,
[M29] [int] NULL ,
[M30] [int] NULL ,
[M31] [int] NULL ,
[M32] [int] NULL ,
[M33] [int] NULL ,
[M34] [int] NULL ,
[M35] [int] NULL ,
[M36] [int] NULL ,
[M37] [int] NULL ,
[M38] [int] NULL ,
[M39] [int] NULL ,
[M40] [int] NULL ,
[M41] [int] NULL ,
[M42] [int] NULL ,
[M43] [int] NULL ,
[M44] [int] NULL ,
[M45] [int] NULL ,
[M46] [int] NULL ,
[M47] [int] NULL ,
[M48] [int] NULL ,
[M49] [int] NULL ,
[M50] [int] NULL ,
[M51] [int] NULL ,
[M52] [int] NULL ,
[M53] [int] NULL ,
[M54] [int] NULL ,
[M55] [int] NULL ,
[M56] [int] NULL ,
[M57] [int] NULL ,
[M58] [int] NULL ,
[M59] [int] NULL ,
[M60] [int] NULL ,
[M61] [int] NULL ,
[M62] [int] NULL ,
[M63] [int] NULL ,
[M64] [int] NULL ,
[M65] [int] NULL ,
[M66] [int] NULL ,
[M67] [int] NULL ,
[M68] [int] NULL ,
[M69] [int] NULL ,
[M70] [int] NULL ,
[M71] [int] NULL ,
[M72] [int] NULL ,
[M73] [int] NULL ,
[M74] [int] NULL ,
[M75] [int] NULL ,
[M76] [int] NULL ,
[M77] [int] NULL ,
[M78] [int] NULL ,
[M79] [int] NULL ,
[M80] [int] NULL ,
[M81] [int] NULL ,
[M82] [int] NULL ,
[M83] [int] NULL ,
[M84] [int] NULL ,
[M85] [int] NULL ,
[M86] [int] NULL ,
[M87] [int] NULL ,
[M88] [int] NULL ,
[M89] [int] NULL ,
[M90] [int] NULL ,
[M91] [int] NULL ,
[M92] [int] NULL ,
[M93] [int] NULL ,
[M94] [int] NULL ,
[M95] [int] NULL ,
[M96] [int] NULL ,
[M97] [int] NULL ,
[M98] [int] NULL ,
[M99] [int] NULL ,
[M100] [int] NULL
)
and LocalNetID, BSCID, SiteID, CellID, StrTime are set index,
the sql i want to query is :
select
LocalNetID, BSCID, SiteID, CellID, StrTime,
Sum(M1) as M1,Sum(M2) as M2,Sum(M3) as M3,Sum(M4) as M4,Sum(M5) as M5,Sum(M6) as M6,Sum(M7) as M7,Sum(M8) as M8,Sum(M9) as M9,Sum(M10) as M10,Sum(M11) as M11,Sum(M12) as M12,Sum(M13) as M13,Sum(M14) as M14,Sum(M15) as M15,Sum(M16) as M16,Sum(M17) as M17,Sum(M18) as M18,Sum(M19) as M19,Sum(M20) as M20,Sum(M21) as M21,Sum(M22) as M22,Sum(M23) as M23,Sum(M24) as M24,Sum(M25) as M25,Sum(M26) as M26,Sum(M27) as M27,Sum(M28) as M28,Sum(M29) as M29,Sum(M30) as M30,Sum(M31) as M31,Sum(M32) as M32,Sum(M33) as M33,Sum(M34) as M34,Sum(M35) as M35,Sum(M36) as M36,Sum(M37) as M37,Sum(M38) as M38,Sum(M39) as M39,Sum(M40) as M40,Sum(M41) as M41,Sum(M42) as M42,Sum(M43) as M43,Sum(M44) as M44,Sum(M45) as M45,Sum(M46) as M46,Sum(M47) as M47,Sum(M48) as M48,Sum(M49) as M49,Sum(M50) as M50,Sum(M51) as M51,Sum(M52) as M52,Sum(M53) as M53,Sum(M54) as M54,Sum(M55) as M55,Sum(M56) as M56,Sum(M57) as M57,Sum(M58) as M58,Sum(M59) as M59,Sum(M60) as M60,Sum(M61) as M61,Sum(M62) as M62,Sum(M63) as M63,Sum(M64) as M64,Sum(M65) as M65,Sum(M66) as M66,Sum(M67) as M67,Sum(M68) as M68,Sum(M69) as M69,Sum(M70) as M70,Sum(M71) as M71,Sum(M72) as M72,Sum(M73) as M73,Sum(M74) as M74,Sum(M75) as M75,Sum(M76) as M76,Sum(M77) as M77,Sum(M78) as M78,Sum(M79) as M79,Sum(M80) as M80,Sum(M81) as M81,Sum(M82) as M82,Sum(M83) as M83,Sum(M84) as M84,Sum(M85) as M85,Sum(M86) as M86,Sum(M87) as M87,Sum(M88) as M88,Sum(M89) as M89,Sum(M90) as M90,Sum(M91) as M91,Sum(M92) as M92,Sum(M93) as M93,Sum(M94) as M94,Sum(M95) as M95,Sum(M96) as M96,Sum(M97) as M97,Sum(M98) as M98,Sum(M99) as M99,Sum(M100) as M100
from
(
select
LocalNetID, BSCID, SiteID, CellID, StrTime,
Sum(M1) as M1,Sum(M2) as M2,Sum(M3) as M3,Sum(M4) as M4,Sum(M5) as M5,Sum(M6) as M6,Sum(M7) as M7,Sum(M8) as M8,Sum(M9) as M9,Sum(M10) as M10,Sum(M11) as M11,Sum(M12) as M12,Sum(M13) as M13,Sum(M14) as M14,Sum(M15) as M15,Sum(M16) as M16,Sum(M17) as M17,Sum(M18) as M18,Sum(M19) as M19,Sum(M20) as M20,Sum(M21) as M21,Sum(M22) as M22,Sum(M23) as M23,Sum(M24) as M24,Sum(M25) as M25,Sum(M26) as M26,Sum(M27) as M27,Sum(M28) as M28,Sum(M29) as M29,Sum(M30) as M30,Sum(M31) as M31,Sum(M32) as M32,Sum(M33) as M33,Sum(M34) as M34,Sum(M35) as M35,Sum(M36) as M36,Sum(M37) as M37,Sum(M38) as M38,Sum(M39) as M39,Sum(M40) as M40,Sum(M41) as M41,Sum(M42) as M42,Sum(M43) as M43,Sum(M44) as M44,Sum(M45) as M45,Sum(M46) as M46,Sum(M47) as M47,Sum(M48) as M48,Sum(M49) as M49,Sum(M50) as M50,Sum(M51) as M51,Sum(M52) as M52,Sum(M53) as M53,Sum(M54) as M54,Sum(M55) as M55,Sum(M56) as M56,Sum(M57) as M57,Sum(M58) as M58,Sum(M59) as M59,Sum(M60) as M60,Sum(M61) as M61,Sum(M62) as M62,Sum(M63) as M63,Sum(M64) as M64,Sum(M65) as M65,Sum(M66) as M66,Sum(M67) as M67,Sum(M68) as M68,Sum(M69) as M69,Sum(M70) as M70,Sum(M71) as M71,Sum(M72) as M72,Sum(M73) as M73,Sum(M74) as M74,Sum(M75) as M75,Sum(M76) as M76,Sum(M77) as M77,Sum(M78) as M78,Sum(M79) as M79,Sum(M80) as M80,Sum(M81) as M81,Sum(M82) as M82,Sum(M83) as M83,Sum(M84) as M84,Sum(M85) as M85,Sum(M86) as M86,Sum(M87) as M87,Sum(M88) as M88,Sum(M89) as M89,Sum(M90) as M90,Sum(M91) as M91,Sum(M92) as M92,Sum(M93) as M93,Sum(M94) as M94,Sum(M95) as M95,Sum(M96) as M96,Sum(M97) as M97,Sum(M98) as M98,Sum(M99) as M99,Sum(M100) as M100
from
(
select
LocalNetID, BSCID, SiteID, CellID, StrTime,
Sum(M1) as M1,Sum(M2) as M2,Sum(M3) as M3,Sum(M4) as M4,Sum(M5) as M5,Sum(M6) as M6,Sum(M7) as M7,Sum(M8) as M8,Sum(M9) as M9,Sum(M10) as M10,Sum(M11) as M11,Sum(M12) as M12,Sum(M13) as M13,Sum(M14) as M14,Sum(M15) as M15,Sum(M16) as M16,Sum(M17) as M17,Sum(M18) as M18,Sum(M19) as M19,Sum(M20) as M20,Sum(M21) as M21,Sum(M22) as M22,Sum(M23) as M23,Sum(M24) as M24,Sum(M25) as M25,Sum(M26) as M26,Sum(M27) as M27,Sum(M28) as M28,Sum(M29) as M29,Sum(M30) as M30,Sum(M31) as M31,Sum(M32) as M32,Sum(M33) as M33,Sum(M34) as M34,Sum(M35) as M35,Sum(M36) as M36,Sum(M37) as M37,Sum(M38) as M38,Sum(M39) as M39,Sum(M40) as M40,Sum(M41) as M41,Sum(M42) as M42,Sum(M43) as M43,Sum(M44) as M44,Sum(M45) as M45,Sum(M46) as M46,Sum(M47) as M47,Sum(M48) as M48,Sum(M49) as M49,Sum(M50) as M50,Sum(M51) as M51,Sum(M52) as M52,Sum(M53) as M53,Sum(M54) as M54,Sum(M55) as M55,Sum(M56) as M56,Sum(M57) as M57,Sum(M58) as M58,Sum(M59) as M59,Sum(M60) as M60,Sum(M61) as M61,Sum(M62) as M62,Sum(M63) as M63,Sum(M64) as M64,Sum(M65) as M65,Sum(M66) as M66,Sum(M67) as M67,Sum(M68) as M68,Sum(M69) as M69,Sum(M70) as M70,Sum(M71) as M71,Sum(M72) as M72,Sum(M73) as M73,Sum(M74) as M74,Sum(M75) as M75,Sum(M76) as M76,Sum(M77) as M77,Sum(M78) as M78,Sum(M79) as M79,Sum(M80) as M80,Sum(M81) as M81,Sum(M82) as M82,Sum(M83) as M83,Sum(M84) as M84,Sum(M85) as M85,Sum(M86) as M86,Sum(M87) as M87,Sum(M88) as M88,Sum(M89) as M89,Sum(M90) as M90,Sum(M91) as M91,Sum(M92) as M92,Sum(M93) as M93,Sum(M94) as M94,Sum(M95) as M95,Sum(M96) as M96,Sum(M97) as M97,Sum(M98) as M98,Sum(M99) as M99,Sum(M100) as M100
from
(
select
LocalNetID, BSCID, SiteID, CellID, StrTime,
Sum(M1) as M1,Sum(M2) as M2,Sum(M3) as M3,Sum(M4) as M4,Sum(M5) as M5,Sum(M6) as M6,Sum(M7) as M7,Sum(M8) as M8,Sum(M9) as M9,Sum(M10) as M10,Sum(M11) as M11,Sum(M12) as M12,Sum(M13) as M13,Sum(M14) as M14,Sum(M15) as M15,Sum(M16) as M16,Sum(M17) as M17,Sum(M18) as M18,Sum(M19) as M19,Sum(M20) as M20,Sum(M21) as M21,Sum(M22) as M22,Sum(M23) as M23,Sum(M24) as M24,Sum(M25) as M25,Sum(M26) as M26,Sum(M27) as M27,Sum(M28) as M28,Sum(M29) as M29,Sum(M30) as M30,Sum(M31) as M31,Sum(M32) as M32,Sum(M33) as M33,Sum(M34) as M34,Sum(M35) as M35,Sum(M36) as M36,Sum(M37) as M37,Sum(M38) as M38,Sum(M39) as M39,Sum(M40) as M40,Sum(M41) as M41,Sum(M42) as M42,Sum(M43) as M43,Sum(M44) as M44,Sum(M45) as M45,Sum(M46) as M46,Sum(M47) as M47,Sum(M48) as M48,Sum(M49) as M49,Sum(M50) as M50,Sum(M51) as M51,Sum(M52) as M52,Sum(M53) as M53,Sum(M54) as M54,Sum(M55) as M55,Sum(M56) as M56,Sum(M57) as M57,Sum(M58) as M58,Sum(M59) as M59,Sum(M60) as M60,Sum(M61) as M61,Sum(M62) as M62,Sum(M63) as M63,Sum(M64) as M64,Sum(M65) as M65,Sum(M66) as M66,Sum(M67) as M67,Sum(M68) as M68,Sum(M69) as M69,Sum(M70) as M70,Sum(M71) as M71,Sum(M72) as M72,Sum(M73) as M73,Sum(M74) as M74,Sum(M75) as M75,Sum(M76) as M76,Sum(M77) as M77,Sum(M78) as M78,Sum(M79) as M79,Sum(M80) as M80,Sum(M81) as M81,Sum(M82) as M82,Sum(M83) as M83,Sum(M84) as M84,Sum(M85) as M85,Sum(M86) as M86,Sum(M87) as M87,Sum(M88) as M88,Sum(M89) as M89,Sum(M90) as M90,Sum(M91) as M91,Sum(M92) as M92,Sum(M93) as M93,Sum(M94) as M94,Sum(M95) as M95,Sum(M96) as M96,Sum(M97) as M97,Sum(M98) as M98,Sum(M99) as M99,Sum(M100) as M100
from
(
select
LocalNetID, BSCID, SiteID, CellID, StrTime,
M1 , M2 , M3 , M4 , M5 , M6 , M7 , M8 , M9 , M10 ,M11 , M12 , M13 , M14 , M15 , M16 , M17 , M18 , M19 , M20 ,M21 , M22 , M23 , M24 , M25 , M26 , M27 , M28 , M29 , M30 ,M31 , M32 , M33 , M34 , M35 , M36 , M37 , M38 , M39 , M40 ,M41 , M42 , M43 , M44 , M45 , M46 , M47 , M48 , M49 , M50 ,M51 , M52 , M53 , M54 , M55 , M56 , M57 , M58 , M59 , M60 ,M61 , M62 , M63 , M64 , M65 , M66 , M67 , M68 , M69 , M70 ,M71 , M72 , M73 , M74 , M75 , M76 , M77 , M78 , M79 , M80 ,M81 , M82 , M83 , M84 , M85 , M86 , M87 , M88 , M89 , M90 ,M91 , M92 , M93 , M94 , M95 , M96 , M97 , M98 , M99 , M100
from examp
) as T1
group by
LocalNetID, BSCID, SiteID, CellID, StrTime
) as T2
group by
LocalNetID, BSCID, SiteID, CellID, StrTime
) as T3
group by
LocalNetID, BSCID, SiteID, CellID, StrTime
) as T4
group by
LocalNetID, BSCID, SiteID, CellID, StrTime
when there is no data in table, it will take more than 3 minutes on my computer!
how can i optimize the sql to speed it?
thks
View 2 Replies
View Related