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

SQL ÖÐROLLUP Ó÷¨

ROLLUP ÔËËã·ûÉú³ÉµÄ½á¹û¼¯ÀàËÆÓÚ CUBE ÔËËã·ûÉú³ÉµÄ½á¹û¼¯¡£ ÏÂÃæÊÇ CUBE ºÍ ROLLUP Ö®¼äµÄ¾ßÌåÇø±ð£º CUBE Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄËùÓÐ×éºÏµÄ¾ÛºÏ¡£ ROLLUP Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄijһ²ã´Î½á¹¹µÄ¾ÛºÏ¡£ ROLLUP Óŵ㣺 £¨£±£©ROLLUP ·µ»Øµ¥¸ö½á¹û¼¯£¬¶ø COMPUTE BY ·µ»Ø¶à¸ö½á¹û¼¯£¬¶ø¶à¸ö½á¹û¼¯»áÔö¼ÓÓ¦ÓóÌÐò´úÂëµÄ¸´ÔÓÐÔ¡£ £¨£²£©ROLLUP ¿ÉÒÔÔÚ·þÎñÆ÷ÓαêÖÐʹÓ㬶ø COMPUTE BY Ôò²»¿ÉÒÔ¡£ £¨£³£©ÓÐʱ£¬²éѯÓÅ»¯Æ÷Ϊ ROLLUP Éú³ÉµÄÖ´Ðмƻ®±ÈΪ COMPUTE BY Éú³ÉµÄ¸üΪ¸ßЧ¡£ ÏÂÃæ¶Ô±ÈÒ»ÏÂGROUP BY ¡¢CUBE ºÍ  ROLLUPºóµÄ½á¹û ´´½¨±í£º CREATE TABLE DEPART
(²¿ÃÅ char(10),Ô±¹¤ char(6),¹¤×Ê int) INSERT INTO DEPART SELECT 'A','ZHANG',100
INSERT INTO DEPART SELECT 'A','LI',200
INSERT INTO DEPART SELECT 'A','WANG',300
INSERT INTO DEPART SELECT 'A','ZHAO',400
INSERT INTO DEPART SELECT 'A','DUAN',500
INSERT INTO DEPART SELECT 'B','DUAN',600
INSERT INTO DEPART SELECT 'B','DUAN',700 ²¿ÃÅ         Ô±¹¤         ¹¤×Ê A             ZHANG     100
A             LI             200
A             WANG      300
A             ZHAO      400
A             DUAN      500
B             DUAN      600
B             DUAN      700   £¨1£©GROUP BY  SELECT ²¿ÃÅ,Ô±¹¤,SUM(¹


Ïà¹ØÎĵµ£º

SQL SERVER

sql server·Ö²¼Ê½ÊÂÎñ½â¾ö·½°¸
ÊÊÓû·¾³
²Ù×÷ϵͳ£ºwindows 2003
Êý¾Ý¿â£ºsql server 2000/sql server 2005
ʹÓÃÁ´½Ó·þÎñÆ÷½øÐÐÔ¶³ÌÊý¾Ý¿â·ÃÎʵÄÇé¿ö
Ò»¡¢  ÎÊÌâÏÖÏó
ÔÚÖ´Ðзֲ¼Ê½ÊÂÎñʱ£¬ÔÚsql server 2005ÏÂÊÕµ½ÈçÏ´íÎó£º
ÏûÏ¢ 7391£¬¼¶±ð 16£¬×´Ì¬ 2£¬¹ý³Ì xxxxx£¬µÚ 16 ÐÐ
ÎÞ·¨Ö´ÐиòÙ×÷£¬ÒòΪÁ´½Ó·þÎñ ......

MS SQL µÝ¹éº¯Êý


/*
select *,dbo.getDeptTree(id) as DeptTree from sysdept
µÝ¹éº¯Êý
*/
CREATE  function getDeptTree(@NodeId int)
returns varchar(8000)
as
begin
    declare @ret varchar(8000),@ParentId int,@len int
    set @len = 0
  &nb ......

SQLÓïÑÔ»ù±¾Óï¾ä½éÉÜ


±íµÄ½¨Á¢
¹ØϵÊý¾Ý¿âµÄÖ÷ÒªÌصãÖ®Ò»¾ÍÊÇÓñíµÄ·½Ê½×éÖ¯Êý¾Ý¡£±íÊÇSQLÓïÑÔ´æ·ÅÊý¾Ý¡¢²éÕÒÊý¾ÝÒÔ¼°¸üÐÂÊý¾ÝµÄ»ù±¾Êý¾Ý½á¹¹¡£ÔÚSQLÓïÑÔÖУ¬±íÓÐÑϸñµÄ¶¨Ò壬ËüÊÇÒ»ÖÖ¶þά±í£¬¶ÔÓÚÕâÖÖ±íÓÐÈçϹ涨£º
1)ÿһÕÅ±í¶¼ÓÐÒ»¸öÃû×Ö£¬Í¨³£³ÆΪ±íÃû»ò¹ØϵÃû¡£±íÃû±ØÐëÒÔ×Öĸ¿ªÍ·£¬×î´ó³¤¶ÈΪ30¸ö×Ö·û¡£
2)Ò»Õűí¿ÉÒÔÓÉÈô¸ÉÁÐ×é³É£ ......

Comparison of SQL and MDX Syntax

          Comparison of SQL and MDX Syntax
The Multidimensional Expressions (MDX) syntax is similar to the syntax of Structured Query Language (SQL). In many ways, the functionality supplied by MDX is also similar to that of SQL; with effort, you can eve ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ