Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 serverÎÊÌâ - Web ¿ª·¢ / ASP

ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º ......

sqlÐÔÄÜÇóÖú - MS-SQL Server / ÒÉÄÑÎÊÌâ

³¡¾°ÈçÏ£º
¿Í»§°Ñ±¸·ÝºÃµÄÊý¾Ý¿â£¬·¢¸øÎÒ£¬ÎÒÔÚ±¾»ú»¹Ô­ºó£¬ÔËÐÐдºÃµÄ´æ´¢¹ý³Ì£¬±È½Ï¿ì£¬²¢ÇÒÔÚʵʩÄDZßÔËÐÐͬÑù±È½Ï¿ì¡£µ«Êǵ±ÊµÊ©ÔÚ¿Í»§ÄDZßÔËÐеÄʱºòËٶȾͷdz£µÄÂý£¬Ê±¼ä³¬³öÁ˳ÌÐòµÄʱ¼äÏÞÖÆ¡£Ô¶³ÌÔÚ¿Í»§ÄÇ ......

SQLÈçºÎÓÅ»¯ÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ

½ñÌì×öÁËÒ»¸ö´æ´¢¹ý³Ì   »·¾³ÊÇSQL2000Êý¾Ý¿â  
´óÖÂÈçÏÂ
½¨Á¢ÁÙʱ±í
¶¨ÒåÔ±¹¤Óαê
        Ñ­»·Ô±¹¤£¨ÊôÓÚ1¸ö¹«Ë¾)  
        ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ