×Ö¶Î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
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
СµÜ£¬×î½üҪתÐÐÈ¥×öoracle¿ª·¢ÁË£¬ÓÉÓÚ´óѧ±Ïҵʱ£¬×ßÁ˸öÍä·£¬ÏÖÔÚºÜСÐÄ£¬ÎÊÏ£¬×öPL/SQLÓÐûÓÐǰ;£¿£¿£¿
µ±È»ÎÒ˵µÄÕâ¸öǰ;ÊÇÖ¸ ÒÔºóÒªÌø²Û£¬Êг¡¶ÔÕâÑùµÄÈ˲ŵÄÐèÇóÁ¿´ó²»´ó£¿£¿
3q ÄÇ¿´À´»¹Ö»ÄÜÏȽӴ ......
ÏÖÔÚÓÐÁ½ÕÅ±í£ºÎÄÕÂÖ÷±íA(articleId,articleTitle)£¬ÎÄÕÂÆÀÂÛ±íB(commentId,articleId,commentTitle)
ÏÖÔÚÎÒÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£ºÁгöÎÄÕÂÁÐ±í£¬ÆäÖÐÿƪÎÄÕ±êÌâÏÂÃæÁгö´ËÎÄÕµÄÇ°2¸öÎÄÕÂÆÀÂÛ£¬ÇëÎÊsqlÓï¾äÔõôд°¡ ......