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

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


Ïà¹ØÎĵµ£º

HibernateµÄÔ­ÉúSQL²éѯ

 ÕÛÌÚÁËÎÒ°ëÌìÖÕÓڸ㶨ÁË
²Î¿¼ÁËÕâ¸öÎÄÕ£ºhttp://doc.javanb.com/hibernate-reference-3-2-0-zh/ch16.html
final static String querySql = "select {enterprise.*}, {dict.*} ,{balancd.*}, {weightinfo.*}  "
   + "from weight_info weightinfo left outer join t_dict dict on {weightinf ......

SQL ServerÈÕÖ¾Çå³ýµÄÁ½ÖÖ·½·¨

 ÔÚʹÓùý³ÌÖдó¼Ò¾­³£Åöµ½Êý¾Ý¿âÈÕÖ¾·Ç³£´óµÄÇé¿ö£¬ÔÚÕâÀï½éÉÜÁËÁ½ÖÖ´¦Àí·½·¨……
¡¡¡¡·½·¨Ò»
¡¡¡¡Ò»°ãÇé¿öÏ£¬SQLÊý¾Ý¿âµÄÊÕËõ²¢²»Äܴܺó³Ì¶ÈÉϼõСÊý¾Ý¿â´óС£¬ÆäÖ÷Òª×÷ÓÃÊÇÊÕËõÈÕÖ¾´óС£¬Ó¦µ±¶¨ÆÚ½øÐд˲Ù×÷ÒÔÃâÊý¾Ý¿âÈÕÖ¾¹ý´ó¡£
¡¡¡¡1¡¢ÉèÖÃÊý¾Ý¿âģʽΪ¼òµ¥Ä£Ê½£º´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆÌ¨¸ùÄ ......

Oracle SQL¾«ÃîSQLÓï¾ä½²½â


--ÐÐÁÐת»» ÐÐתÁÐ
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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ