sql code
Õâsql Óï¾äдµÄÕæµÄºÜ²»´í!
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([col1] bigint,[col2] varchar(6),[col3] varchar(6))
insert [tb]
select 130126200201000275,'ÍõÎÄϼ','½ù´¨´¨' union all
select 130126200201000275,'ÍõÎÄϼ','½ù澤' union all
select 130126200201000275,'ÍõÎÄϼ','aaaa' union all
select 130126200201000276,'ÖÜ書¶ð','³Ì˼³¬' union all
select 130126200201000276,'ÖÜ書¶ð','³Ìٮٮ' union all
select 130126200201000277,'風¾Õ','³ÌÇàÇà' union all
select 130126200201000277,'風¾Õ','³Ì¶þС' union all
select 130126200201000278,'張Ó¢ÌÒ','³Ì´ó慶' union all
select 130126200201000278,'張Ó¢ÌÒ','³ÌС»¨'
--------------¿ªÊ¼²éѯ--------------------------
select * from tb
select col2,col3 from
(
select col1,col2,col3 from [tb] t
where not exists(select * from tb where col1=t.col1 and col2=t.col2 and col3>t.col3)
union all
select col1,'',col3 from [tb] t
where exists(select 1 from tb where col1=t.col1 and col2=t.col2 and col3>t.col3)
)T
order by col1,col3 desc
Ïà¹ØÎĵµ£º
¾µäSQLÓï¾ä´óÈ«
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢Ë ......
1. Nested Loop Join(ǶÌ×Ñ»·Áª½á)
Ëã·¨£º
Æä˼·Ï൱µÄ¼òµ¥ºÍÖ±½Ó£º¶ÔÓÚ¹ØϵRµÄÿ¸öÔª×é r ½«ÆäÓë¹ØϵSµÄÿ¸öÔª×é s ÔÚJOINÌõ¼þµÄ×Ö¶ÎÉÏÖ±½Ó±È½Ï²¢É¸Ñ¡³ö·ûºÏÌõ¼þµÄÔª×顣д³Éα´úÂë¾ÍÊÇ£º
´ú¼Û£º
±»Áª½áµÄ±íËù´¦ÄÚ²ã»òÍâ²ãµÄ˳Ðò¶Ô´ÅÅÌI/O¿ªÏúÓÐ×ŷdz£ÖØÒªµÄÓ°Ïì¡£¶øCPU¿ªÏúÏà¶ÔÀ´ËµÓ°Ïì½ÏС£¬Ö÷ÒªÊÇÔª×é¶ÁÈ ......
¡¡ÔÚSQL Server 2005Êý¾Ý¿âÖÐʵÏÖ×Ô¶¯±¸·ÝµÄ¾ßÌå²½Öè:
¡¡¡¡1¡¢´ò¿ªSQL Server Management Studio
¡¡¡¡2¡¢Æô¶¯SQL Server´úÀí
¡¡¡¡3¡¢µã»÷×÷Òµ->н¨×÷Òµ
¡¡¡¡4¡¢"³£¹æ"ÖÐÊäÈë×÷ÒµµÄÃû³Æ
¡¡¡¡5¡¢Ð½¨²½Ö裬ÀàÐÍÑ¡T-SQL£¬ÔÚÏÂÃæµÄÃüÁîÖÐÊäÈëÏÂÃæÓï¾ä£¨Çë¸ù¾Ý×Ô¼ºµÄʵ¼ÊÇé¿ö¸ü¸Ä£¬D:\sql2005\\back\¸ÄΪ×Ô¼ºµÄ±¸· ......
--ÐÐÁÐת»» ÐÐתÁÐ
DROP TABLE t_change_lc;
CREATE TABLE t_change_lc (card_code VARCHAR2(3), q NUMBER, bal NUMBER);
INSERT INTO t_change_lc
SELECT '001' card_code, ROWNUM q, trunc(dbms_random.VALUE * 100) bal from dual CONNECT BY ROWNUM <= 4
UNION
SELECT '002' card_code, ROWNUM q, trunc(d ......
Vista³öÁËÃûµÄ¼æÈÝÐÔÎÊÌâ¶à£¬ºÜ¶àÈËÒ²¿àÓÚSQL SERVER²»ÄÜ°²×°ÔÚVistaÏ¡£ÏÖÔÚÎÒ½«×Ô¼ºµÄ°²×°¹ý³Ì˵Ï£º
²Ù×÷ϵͳ£ºWindows Vista Home Basic
´¦Àíµ¥Ôª£ºInter P8600 2.40GHz
Ö÷´æ´¢Æ÷£º2G
Íâ´æ´¢Æ÷£º250G
Èí¼þ×¼±¸£º£¨¶¼¿ÉÒÔÔÚ΢Èí¹Ù·½ÍøÕ¾ÕÒµ½£¬¾ùÃâ·Ñ£©
1.SQL SERVER 2005 EXPRESS£¨40.6M ......