Õâ¸ö sqlɾ³ýÓï¾äÔõôд£¿ - MS-SQL Server / »ù´¡Àà
SQL code:
declare @tb1 table(a varchar(20),b varchar(20))
insert into @tb1 select 'a101','b11121'
insert into @tb1 select 'a102','b00012'
select * from @tb1
declare @tb2 table(id int,c varchar(20))
insert into @tb2 select 1,'a101'
insert into @tb2 select 2,'b11121'
insert into @tb2 select 3,'a000'
insert into @tb2 select 4,'c1001'
select * from @tb2
ÎÒÏÖÔÚÒª°Ñ @tb2 ÖÐc×Ö¶Î ÔÚ @tb1 ÖÐÓÐÖØ¸´µÄÊý¾Ýɾ³ý£¬±£Áô@tb2 ÖÐid ½ÏСµÄ
Èç
@tb1ÖÐ 'a101',' b11121' ÔÚͬһÐУ¬
¶ø@tb2 ÖÐc×Ö¶ÎÓÐ
1 a101
2 b11121
3 a000
4 c1001
¾Íɾ³ýµÚ¶þÐУ¬×îºóµÃµ½½á¹û
1 a101
3 a000
4 c1001
Õâ¸ösqlÔõôд£¿
ÐÞ¸ÄÒ»ÏÂ
SQL code:
declare @tb1 table(id int,a varchar(20),b varchar(20))
insert into @tb1 select 1,'a101','b11121'
insert into @tb1 select 2,'a102','b00012'
select * from @tb1
declare @tb2 table(id int,c varchar(20))
insert into @tb2 select 1,'a101'
insert into @tb2 select 2,'b11121'
insert into @tb2 select 3,'a000'
insert into @tb2 select 4,'c1001'
select * from @tb2
Á½±íid¶¼ÊÇΨһµÄ
ÎÒÏÖÔÚÒª°Ñ @tb2 ÖÐc×Ö¶Î ÔÚ @tb1 ÖÐÓÐÖØ¸´µÄÊý¾Ýɾ³ý£¬±£Áô@tb2 ÖÐid ½ÏСµÄ
Èç
@tb1ÖÐ 'a101',' b11121' ÔÚͬһÐУ¬
¶ø@tb2 ÖÐc×Ö¶ÎÓÐ
1 a101
2 b11121
3 a000
4 c1001
¾Íɾ³ýµÚ¶þÐУ¬×îºóµÃµ½½á¹û
1
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
Çë½Ì¸ßÊÖ£º
ÒÔÏÂÊÇÊý¾Ý¿âÖеÄÈýÌõ¼Ç¼£¬Ó¢ÎÄΪ×Ö¶ÎÃû³Æ
id planname TaskBeginTime Status
329 2010Äê03 ......
Çó¸övbÖеÄsqlÓï¾äµÄд·¨£¬´ÎsqlÓï¾äµÄÓ÷¨ÊÇ·ÖÒ³³ÌÐò
ÎÒдµÄÈçÏ£ºÆäÖÐAÊÇÓÃÀ´½ÓÊÕÿҳÏÔʾµÄ¼Ç¼µÄÌõÊý£¬BÊÇÓÃÀ´½ÓÊÕÏÔʾµÄµ±Ç°µÄÒ³Ãæ.
sqltext="select top A * from log where id not in(select top ( ......
²éѯѧÉúƽ¾ù³É¼¨¼°ÆäÃû´Î
SELECT 1+(SELECT COUNT( distinct ƽ¾ù³É¼¨)
from (SELECT S#,AVG(score) AS ƽ¾ù³É¼¨
from SC&n ......