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

ÇóÒ»¸öSQLÓï¾ä - MS-SQL Server / »ù´¡Àà

×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101

ÏëÒªµÄ½á¹ûÊÇ:

1,Name1....test1,3,99
1,Name1....test1,4,101

Æäʵ¾ÍÊÇÏÈ°´ParentID·Ö×é,ÔÙÈ¡³öStatus×î´óµÄ¼Ç¼

Çë´ó¼Ò°ïæһÏ°¡.





×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID 
1,Name1....test1,1,99 
2,Name1....test1,3,99 
3,Name2....test2,1,101 
4,Name2....test2,3,101 
5,Name3....test3,2,101 
6,Name7....test9,4,101 

ÏëÒªµÄ½á¹ûÊÇ: 

2,Name1....test1,3,99 
6,Name7....test9,4,101 

ÕâÑù¸üÇå³þÒ»µã


SQL code:
---²âÊÔÊý¾Ý---
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([×Ö¶Î1] int,[×Ö¶Î2] varchar(5),[¶ÎN] varchar(5),[Status] int,[ParentID] int)
insert [tb]
select 1,'Name1','test1',1,99 union all
select 2,'Name1','test1',3,99 union all
select 3,'Name2','test2',1,101 union all
select 4,'Name2','test2',3,101 union all
select 5,'Name3','test3',2,101 union all
select 6,'Name7','test9',4,101

---²éѯ---
select *
from tb t
where not exists(select 1 from tb where ParentID=t.ParentID and Status>t.Status)

---½á¹û---
×Ö¶Î1


Ïà¹ØÎÊ´ð£º

sqlת»»ÎÊÌ⣬¼±£¡ - ÉçÇøÖ§³Ö / ¡¶³ÌÐòÔ±¡·ÔÓÖ¾

select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......

ASPÁ´½ÓSQLµÄ¼òµ¥µÇ½½çÃæ - .NET¼¼Êõ / ASP.NET

protected void btnLogin_Click(object sender, EventArgs e)
  {
  SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......

pl/sql - Oracle / ¿ª·¢

СµÜ£¬×î½üҪתÐÐÈ¥×öoracle¿ª·¢ÁË£¬ÓÉÓÚ´óѧ±Ïҵʱ£¬×ßÁ˸öÍä·£¬ÏÖÔÚºÜСÐÄ£¬ÎÊÏ£¬×öPL/SQLÓÐûÓÐǰ;£¿£¿£¿
µ±È»ÎÒ˵µÄÕâ¸öǰ;ÊÇÖ¸ ÒÔºóÒªÌø²Û£¬Êг¡¶ÔÕâÑùµÄÈ˲ŵÄÐèÇóÁ¿´ó²»´ó£¿£¿

3q ÄÇ¿´À´»¹Ö»ÄÜÏȽӴ ......

ÇóÒ»sqlÓï¾ä - MS-SQL Server / ÒÉÄÑÎÊÌâ

ÏÖÔÚÓÐÁ½ÕÅ±í£ºÎÄÕÂÖ÷±íA(articleId,articleTitle)£¬ÎÄÕÂÆÀÂÛ±íB(commentId,articleId,commentTitle)
ÏÖÔÚÎÒÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£ºÁгöÎÄÕÂÁÐ±í£¬ÆäÖÐÿƪÎÄÕ±êÌâÏÂÃæÁгö´ËÎÄÕµÄÇ°2¸öÎÄÕÂÆÀÂÛ£¬ÇëÎÊsqlÓï¾äÔõôд°¡ ......

sql - MS-SQL Server / ÒÉÄÑÎÊÌâ

sqlµÄÈí¼þÔÚÄÄÀï¿ÉÒÔÏ°¡£¡ÔÚÍøÉÏÕÒÁËÂù¶à¶¼Óò»ÁË°¡

Ëæ±ã¸ãÒ»D°æ°É£¬

ѸÀ×µÚÒ»¸ö¾Í¿ÉÒÔÓÃ
2000,2005¶¼ÕâÑù

http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ