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

ÇÉÓÃSQLÖеÄWITH£¨Ê÷ÐͽṹÊý¾ÝµÄ²éѯ£©

Èç¹û±íÖдæ·ÅµÄÊý¾ÝÊÇÊ÷Ðνṹ£¬µ±ÖªµÀijһ¸ö½ÚµãµÄֵʱ£¬Í¬Ê±ÏëÈ¡µÃËüËùÓÐ×Ó½ÚµãµÄÊý¾Ý¡£
±í½á¹¹£º
        
         
 ±íÖдæ·ÅµÄÊDz¿ÃÅ×éÖ¯½á¹¹£¬ BMN_CD²¿ÃÅ£¬SSK_KAISO_LVÊǽײ㣬BMN_MKJ²¿ÃÅÃû³Æ£¬JOI_KAISO_LVÉÏλ½×²ã£¬JOI_BMN_CDÉÏλ²¿ÃÅ¡£
¼ìË÷SQL :
 
    WITH Moduals (BMN_CD, SSK_KAISO_LV, BMN_MKJ, BMN_NM_RYKS, SKI_FLG, JOI_KAISO_LV, JOI_BMN_CD) AS (SELECT
    T130A.BMN_CD,
    T130A.SSK_KAISO_LV,
    T130A.BMN_MKJ,
    TRIM(T130A.BMN_NM_RYKS) BMN_NM_RYKS,
    T130A.SKI_FLG,
    T130A.JOI_KAISO_LV,
    T130A.JOI_BMN_CD
from
    T130 T130A
WHERE
    T130A.BMN_CD = 'B00011' AND
UNION ALL
SELECT
    T130B.BMN_CD,
    T130B.SSK_KAISO_LV,
    T130B.BMN_MKJ,
    TRIM(T130B.BMN_NM_RYKS) BMN_NM_RYKS,
    T130B.SKI_FLG,
    T130B.JOI_KAISO_LV,
    T130B.JOI_BMN_CD
from
    T130 T130B
INNER JOIN Moduals T130C
   ON T130B.JOI_KAISO_LV = T130C.SSK_KAISO_LV
  AND T130B.JOI_BMN_CD = T130C.BMN_CD
)
SELECT Moduals.BMN_CD,SSK_KAISO_LV, BMN_MKJ, BMN_NM_RYKS, SKI_FLG, JOI_KAISO_LV, JOI_BMN_CD from Moduals
¡¾ WHERE ………… ¡¿
Èç¹û¶Ô¼ìË÷½á¹û»¹ÓÐÏÞÖƵĻ°£¬¿ÉÒÔ¼ÓWHEREÓï¾ä½øÐÐÏÞÖÆ¡£¡£¡£¡£¡£¡£¡£¡£
¼ìË÷½á¹û£º
         


Ïà¹ØÎĵµ£º

SQL Server 2005ÖÐдÎļþµÄ·½·¨

--´´½¨Ð´ÎļþµÄ´æ´¢¹ý³Ì
ALTER proc [dbo].[p_movefile]
 @filename varchar(1000),--Òª²Ù×÷µÄÎı¾ÎļþÃû  
 @text varchar(8000),   --ҪдÈëµÄÄÚÈÝ
 @obj int
as  
begin
 declare @err  int,
   @src  varchar(255),
 &n ......

¸ß¼¶ SQL 1

1 µ±Ê¹ÓÃgroup byʱ£¬Î´ÔÚgroup by ²¿·ÖÓõ½µÄ±íÁÐÔÚs e l e c t²¿·Ö³öÏÖʱ±ØÐëʹÓ÷Ö×麯Êý¡£
select last_name, state_cd, sum(sales) from customer group by last_name;
ERROR at line 1:
ORA-00979: not a GROUP BY expression.
state_cdÓ¦¸ÃʹÓ÷Ö×麯Êý£¬m a x ( )¡¢m i n ( )¡¢s u m ( )¡¢c o u n t ( )»òa v g ......

Oracleά»¤³£ÓÃSQLÓï¾ä»ã×Ü


¡¡ÈçºÎÔ¶³ÌÅжÏOracleÊý¾Ý¿âµÄ°²×°Æ½Ì¨
¡¡¡¡select * from v$version;
¡¡¡¡²é¿´±í¿Õ¼äµÄʹÓÃÇé¿ö
¡¡¡¡select sum(bytes)/(1024*1024) as free_space,tablespace_name
¡¡¡¡from dba_free_space
¡¡¡¡group by tablespace_name;
¡¡¡¡SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
¡¡¡¡(B.BYTE ......

SQL ѧϰ±Ê¼ÇÖ®Ë÷Òý

----use pubs-sales
-----´´½¨Ë÷Òý
create index index_name
on authors(au_lname)
--´´½¨Ë÷Òýºó±íÖÐËùÓеÄÊý¾Ý¸ú֮ǰûÓÐÇø±ð
select * from authors
--µ¥¶À²éË÷ÒýÁÐ
select au_lname from authors
--Ç¿ÖÆʹÓ÷Ǵؼ¯Ë÷Òý
select * from  authors with(index(index_name))
--¶à×ֶηǴؼ¯Ë÷Òý
create inde ......

Íü¼ÇSQL ServerµÄSAÓû§ÃÜÂë½â¾ö·½·¨


×÷Õß:Íø·ÓÎÏÀ@youxia.org
·¢²¼Ê±¼ä:2005-9-25 11:48:18 ÎÄÕÂÀ´Ô´:youxia.org
̨ʽ»úºÍ±¾±¾·Ö±ð°²×°ÁËMS SQL Server£¬·½±ã×ö²âÊÔÓÃ
½á¹ûʱ¼ä³¤ÁË£¬
̨ʽ»úSQL ServerµÄÃÜÂëÍü¼ÇÁË……
ÄѵÀ……ûÓа취ÁËÂ𣿗—No£¡
¾­¹ýÒ»Õó×ÓÓôÃÆ£¬ÓÎÏÀÔÚ°Ù¶ÈËѵ½ÁË·½·¨£º
ÏÖÔÚÄãµÄ
ÆóÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ