Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

ORA 07445 Óë PL/SQL Developer °¸ÀýÒ»Ôò

ORA-07445 Óë PL/SQL Developer °¸ÀýÒ»Ôò
×÷Õߣºeygle |English Version ¡¾×ªÔØÊ±ÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷¡¿
Á´½Ó£ºhttp://www.eygle.com/archives/2009/02/ora_07445_plsql_developer.html
--------------------------------------------------------------------------------
ǰ¼¸Ì죬ÓÖÓÐÒ»¸ö ......

¸öÈË×ܽáµÄ¼¸Ìõ±È½ÏÓÐÒâ˼µÄsqlÓï¾ä


 
--------------------------------------------------------------------
-- ×÷ÕߣºÕŰ®¹ú
-- ÈÕÆÚ£º2010-01-23 15:00:17
-- ÃèÊö: һЩ±È½ÏÓÐÒâ˼µÄSQLÓï¾ä
-- Version:
--    Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86)
--    Feb  9 2007 22:47:0 ......

´«ÖDz¥¿Íjavaѧϰ sql¼òµ¥²éѯÓï¾ä

½ñÌìÎÒѧϰÁËsqlµÄ¼òµ¥²éѯÓï¾ä£¬
 
һЩ»ù±¾µÄ¸ÅÄ
1                  ϵͳȨÏÞ£ºÊý¾Ý¿âÖеĶÔÏó£¬ ±í£¬´´½¨±í£¬É¾³ý±í
2           ¶ÔÏóȨÏÞ£º¶ÔÊý¾ÝµÄÔö¡¢É¾¡¢¸Ä¡¢²é¡ ......

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

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

Èճ̰²ÅÅÉú³ÉµÄsqlÓï¾ä

select *
from
(select [id]=row_number() over (order by getdate()),
        date=convert(varchar(8),dateadd(dd,number,'2010-01-01'),112)
        from
        (select number from master..spt ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ