|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
使用C和C++编写,并使用了多种编译器进行测试,保证源代码的可移植性问:
表布局以下
timeneRegUserOpenUserCountSysrate
2006-10-1315:00WHMSC141.61288254256915
2006-10-1315:00WHMSC236.12255287226457
2006-10-1315:00WHMSC324.34191782169963
2006-10-1315:00WHMSC418.04150165133202
2006-10-1315:00WHMSC545.9322620287878
2006-10-1315:00WHMSC636.5239202214127
2006-10-1315:00WHMSC746.81331721297042
2006-10-1315:00WHMSC846.38240098215498
2006-10-1315:00WHMSC951.58323802292248
2006-10-1315:00WHMSCA136.81304640271097
2006-10-1315:00WHMSCB36.79316382278293
2006-10-1315:00WHMSCC38.69310090277396
2006-10-1315:00WHMSCD22.26206749182311
如今要做成如许
timene字段值
2006-10-1315:00WHMSC1RegUser41.61
2006-10-1315:00WHMSC1OpenUserCount288254
2006-10-1315:00WHMSC1Sysrate256915
...两头省略............
2006-10-1315:00WHMSCDRegUser22.26
2006-10-1315:00WHMSCDOpenUserCount206749
2006-10-1315:00WHMSCDSysrate182311
----到了下一个小时仍是如许,按time,ne分组,如
timene字段值
2006-10-1316:00WHMSC1RegUser41.61
2006-10-1316:00WHMSC1OpenUserCount288254
2006-10-1316:00WHMSC1Sysrate256915
...两头省略............
2006-10-1316:00WHMSCDRegUser22.26
2006-10-1316:00WHMSCDOpenUserCount206749
2006-10-1316:00WHMSCDSysrate182311
----------------------------------------------------------------------
答:
ifobject_id(pub..tab)isnotnull
droptabletab
go
createtabletab
(
timedatetime,
nevarchar(10),
ResUservarchar(10),
openusercountvarchar(10),
sysratevarchar(10)
)
insertintotab(time,ne,ResUser,openusercount,sysrate)values(2006-10-1315:00,WHMSC1,41.61,288254,256915)
insertintotab(time,ne,ResUser,openusercount,sysrate)values(2006-10-1315:00,WHMSC2,36.12,255287,226457)
insertintotab(time,ne,ResUser,openusercount,sysrate)values(2006-10-1316:00,WHMSC1,41.62,288256,256916)
insertintotab(time,ne,ResUser,openusercount,sysrate)values(2006-10-1316:00,WHMSC2,36.16,255286,226456)
selectconvert(varchar(16),time,120)astime,ne,ResUseras字段,ResUseras值fromtabunion
selectconvert(varchar(16),time,120)astime,ne,openusercountas字段,openusercountas值fromtabunion
selectconvert(varchar(16),time,120)astime,ne,sysrateas字段,sysrateas值fromtab
orderbytime,ne
droptabletab
--了局
timene字段值
-------------------------------------------------
2006-10-1315:00WHMSC1openusercount288254
2006-10-1315:00WHMSC1ResUser41.61
2006-10-1315:00WHMSC1sysrate256915
2006-10-1315:00WHMSC2openusercount255287
2006-10-1315:00WHMSC2ResUser36.12
2006-10-1315:00WHMSC2sysrate226457
2006-10-1316:00WHMSC1openusercount288256
2006-10-1316:00WHMSC1ResUser41.62
2006-10-1316:00WHMSC1sysrate256916
2006-10-1316:00WHMSC2openusercount255286
2006-10-1316:00WHMSC2ResUser36.16
2006-10-1316:00WHMSC2sysrate226456
(所影响的行数为12行)
如果某个数据列里包含许多重复的值,就算为它建立了索引也不会有很好的效果。比如说,如果某个数据列里包含的净是些诸如“0/1”或“Y/N”等值,就没有必要为它创建一个索引。 |
|