Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Sql Server ×Ö·û´®¾ÛºÏº¯Êý

 Sql Server ÓÐÈçϼ¸Ö־ۺϺ¯ÊýSUM¡¢AVG¡¢COUNT¡¢COUNT(*)¡¢MAX ºÍ MIN£¬µ«ÊÇÕâЩº¯Êý¶¼Ö»ÄܾۺÏÊýÖµÀàÐÍ£¬ÎÞ·¨¾ÛºÏ×Ö·û´®¡£Èçϱí:AggregationTable
Id Name
1 ÕÔ
2 Ç®
1 Ëï
1 Àî
2 ÖÜ
Èç¹ûÏëµÃµ½ÏÂͼµÄ¾ÛºÏ½á¹û
Id Name
1 ÕÔËïÀî
2 Ç®ÖÜ
ÀûÓÃSUM¡¢AVG¡¢COUNT¡¢COUNT(*)¡¢MAX ºÍ MINÊÇÎÞ·¨×öµ½µÄ¡£ÒòΪÕâЩ¶¼ÊǶÔÊýÖµµÄ¾ÛºÏ¡£²»¹ýÎÒÃÇ¿ÉÒÔͨ¹ý×Ô¶¨Ò庯ÊýµÄ·½Ê½À´½â¾öÕâ¸öÎÊÌâ¡£
1.Ê×ÏȽ¨Á¢²âÊÔ±í£¬²¢²åÈë²âÊÔÊý¾Ý£º
view plaincopy to clipboardprint?
create table AggregationTable(Id int, [Name] varchar(10))  
go  
insert into AggregationTable  
    select 1,'ÕÔ' union all  
    select 2,'Ç®' union all  
    select 1,'Ëï' union all  
    select 1,'Àî' union all  
    select 2,'ÖÜ' 
go 
create table AggregationTable(Id int, [Name] varchar(10))
go
insert into AggregationTable
 select 1,'ÕÔ' union all
 select 2,'Ç®' union all
 select 1,'Ëï' union all
 select 1,'Àî' union all
 select 2,'ÖÜ'
go
2.´´½¨×Ô¶¨Òå×Ö·û´®¾ÛºÏº¯Êý
view plaincopy to clipboardprint?
Create FUNCTION AggregateString  
(  
    @Id int 
)  
RETURNS varchar(1024)  
AS  
BEGIN  
    declare @Str varchar(1024)  
    set @Str = '' 
    select @Str = @Str + [Name] from AggregationTable  
    where [Id] = @Id  
    return @Str  
END  
GO 
Create FUNCTION AggregateString
(
 @Id int
)
RETURNS varchar(1024)
AS
BEGIN
 declare @Str varchar(1024)
 set @Str = ''
 select @Str = @Str + [Name] from AggregationTable
 where [Id] = @Id
 return @Str
END
GO
3.Ö´ÐÐÏÂÃæµÄÓï¾ä£¬²¢²é¿´½á¹û
view plaincopy to clipboardprint?
select dbo.Aggregate


Ïà¹ØÎĵµ£º

SQLÀàÐÍ

SQL ServerÊý¾ÝÀàÐÍ2009Äê02ÔÂ02ÈÕ ÐÇÆÚÒ» 11:20Êý¾ÝÀàÐÍÊÇÊý¾ÝµÄÒ»ÖÖÊôÐÔ£¬ÊÇÊý¾ÝËù±íʾÐÅÏ¢µÄÀàÐÍ¡£ÈκÎÒ»ÖÖÓïÑÔ¶¼ÓÐËü×Ô¼ºËù¹ÌÓеÄÊý¾ÝÀàÐÍ£¬SQL ServerÌṩһÏÂ25ÖÖ¹ÌÓеÄÊý¾ÝÀàÐÍ¡£ SQL ServerÊý¾ÝÀàÐÍÒ»ÀÀ±í
¡¡¡¡·Binary [(n)]
·Varbinary [(n)]
·Char [(n)]
·Varchar[(n)]
· ......

SQL ServerÊÂÎñÈÕÖ¾½éÉÜ

SQL ServerÖеÄÊý¾Ý¿â¶¼ÊÇÓÉÒ»»ò¶à¸öÊý¾ÝÎļþÒÔ¼°Ò»»ò¶à¸öÊÂÎñÈÕÖ¾Îļþ×é³ÉµÄ¡£
¹ËÃû˼Ò⣬Êý¾ÝÎļþÖ÷Òª´æ´¢Êý¾Ý¿âµÄÊý¾Ý£¬°üÀ¨Êý¾Ý¿âÄÚÈݽṹ£¬Êý¾ÝÒ³£¬Ë÷ÒýÒ³µÈµÈ¡£ÄÇôÊÂÎñÈÕÖ¾µ½µ×ÊǸÉʲôµÄÄØ£¿ËüÖ÷ÒªÊÇÓÃÀ´±£´æÊý¾Ý¿âÐ޸ļǼµÄ£¬ÈçÏÂͼ£º
SQL ServerµÄ¹¤×÷Ô­ÀíΪʲôÕâÑùÄØ£¿ÎªÊ²Ã´²»°ÑÊý¾ÝÁ¢¿ÌдÈëÊý¾ÝÎļþÄØ£¿Ô­ ......

´«ÖDz¥¿Íjavaѧϰ sql¶ÔÏó

ÎÒ½ñÌìѧϰÁËOracleÊý¾Ý¿âÈçºÎÐ޸ıíµÄ֪ʶ£¬ÊÇ·ëÍþÀÏʦ½²µÄ¿Î£¬ÎÒ×öÁ˼òµ¥µÄ¼Ç¼£º
1.ÔÚ±íÖвåÈëеÄÁУº
  alter table tablename
  add city varchar£¨2£© default 'rr' //¸³Ä¬ÈÏÖµ
2.Ð޸ıíÖеÄÁУº
  alter table tablename
  modify city varchar£¨20£©
3.ɾ³ý±íÖеÄÁУº
  alter t ......

´¦ÀíSQL ServerÊý¾Ý¿âÖеĹÂÁ¢Óû§(ͼ)

´¦ÀíSQL ServerÊý¾Ý¿âÖеĹÂÁ¢Óû§(ͼ)
°ÑÊý¾Ý¿â´ÓÒ»¸ö·þÎñÆ÷ʵÀý¸½¼ÓºÍ»Ö¸´µ½ÁíÒ»¸öʵÀýÖÐÊÇÊý¾Ý¿â¹ÜÀíÔ±Ö´Ðеij£¼ûµÄÈÎÎñ¡£¸½¼Ó»òÕ߻ָ´Ò»¸öÊý¾Ý¿âÖ®ºó£¬Ö®Ç°ÔÚÊý¾Ý¿âÖд´½¨ºÍÅäÖõĵǼÃûÒѾ­²»ÄÜ·ÃÎÊÁË¡£Õâ¸öÎÊÌâ×î³£¼ûµÄÖ¢×´ÊÇÓ¦ÓóÌÐò»áÓöµ½µÇ¼ʧ°ÜµÄ´íÎ󣬻òÕßÊǵ±ÄãÊÔ×ŰѵǼÃûÌí¼Óµ½Êý¾Ý¿âÖÐʱ£¬Äã¿ÉÄÜ»áµÃµ½Ò» ......

SQL ServerÊý¾Ý¿âʱ³öÏÖ¹ÂÁ¢Óû§È¨ÏÞÎÊÌâµÄ½â¾ö°ì

--×Ô¼ººÜÓÞ´ÀµÄ×ö·¨£¬ÒÔΪֱ½Óɾ³ýÊý¾Ý¿âÓû§Ãû£¬ÔÙ´Óд´½¨Óû§µÇ¼ÃûºÍÊý¾Ý¿âÓû§Ãû¡£
--×Ô¼ºÒÔΪ¿ÉÒÔÖ±½Ó´´½¨ÓëÖ®Ô­ÏÈÒ»ÑùµÄÊý¾Ý¿âµÇ¼Ãû¾Í¿ÉÒÔ
--µ«ÕâЩ²Ù×÷ÊDz»Æð×÷ÓõÄ
--Ô­Òò
--µ±Ó³Éä¹ÂÁ¢Óû§Ê±£¬Ö÷´ÓÊý¾Ý¿âÖеÄSID½«·ÖÅ䏸¹ÂÁ¢Óû§£¬ËùÒÔÿ´ÎÒ»¸öÊý¾Ý¿â±¸¸½¼Ó»òÕß»¹Ô­Ê±£¬--SIDÔÚSQL Server µÇ¼ÃûºÍÊý¾Ý¿âÓû ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ