mssql Çó¶à×Ö¶Î×î´óÖµ
//Ïà¹Øsql
SQL code:
create table tb1
(
tId int,
tName nvarchar(20),
class1 int,
class2 int
)
insert into tb1
select 1,'test',10,20
union all
select 1,'test1',20,35
union all
select 1,'test2',30,30
union all
select 2,'test21',30,85
union all
select 2,'test22',50,75
union all
select 3,'test31',60,65
union all
select 3,'test32',70,70
//µ¥¸ö×ֶεĻᣬÏÂÃæÊÇÇ󵥸ö×ֶεÄ
SQL code:
select a.* from tb1 a,(select tId,max(class1) as maxT from tb1 group by tId) b
where a.tId=b.tId and a.class1=b.maxT order by a.tId
//Êý¾ÝÏÔʾÈçÏÂ
SQL code:
tId tName class1 class2
1 test2 30 30
2 test22 50 75
3 test32 70 70
//ÎÒÏëÏÔʾΪ
SQL code:
tId tName maxClass
1 test2 35
2 test22 85
3 test32 70
ÎÒÏëÒªµÄ½á¹û¾ÍÊÇclass1,class2²»Çø·Ö£¬È¡×î´óÖµ¡£
//лл¡£
SELECT TID,TNAME,MAX(CLASS1 )
from (
SELECT TID,TNAME,CLASS1 from TB
UNION
Ïà¹ØÎÊ´ð£º
ÏÖÓÐÒ»¸öASP+mssqlµÄÍøÕ¾£¬±»¹ÒÂíÁË£¬½«ÀïÃæÒ»¸ö±íÖеÄntext×ֶιÒÂí¹ÒÂí£¬¡°<script src=http://ľÂíµØÖ·></script>¡±,µÄ·½Ê½ÊÇ£¬²»¶ÏµØÐ޸ĸÃ×ֶεÄÖµ£¬Ö±½Ó¼ÓÔÚ×îºóµÄ£¬Ê±¼ä³¤ÁË£¬¿ÉÒÔ¿´µ½¸Ã×Ö¶ÎÖÐÓÐ ......
ÀýÈ磺select a.* from (select id,code from b left join c on b.id=c.id)a where id=1
ÕâÀïµÄwhere ÔÚÖ´ÐеÄʱºò£¬ where »áÓÅ»¯ÊÇ·ñ½øÈ뵽СÀ¨ºÅÀïÃæÖ´ÐÐ?????
SQL code:
select id,code from b left join ......
·´ÕýÎÒÊǾ³£·Ö²»Çå¡¡
¼ÌÐøÉ¢·Ö
µÚÒ»¸ö±ÕÔ´£¬µÚ¶þ¸ö¿ªÔ´£¬µÚÈý¸öûŮÈËÔµ¡¡
LZÄ㻹ÓпÉÓ÷Öô£¿
ÒýÓÃ
LZÄ㻹ÓпÉÓ÷Öô£¿
5·Ö
ÒýÓÃ
µÚÒ»¸ö±ÕÔ´£¬µÚ¶þ¸ö¿ªÔ´£¬µÚÈý¸öûŮÈËÔµ¡¡
ÓÐÒâ˼¡£¿´±êÌ ......
»ù´¡±íA¡¢BÈçͼ£¬ÓÉÓÚÒ»ÌõÐÂÎÅÖпÉÄÜÓжàÕÅͼƬ£¬ËùÒÔBÖлá³öÏÖ¶à¸öͼƬ±àºÅ¶ÔÒ»¸öÐÂÎűàºÅµÄÇé¿ö¡£
Çó´´½¨C±í£¨ÊÓͼ£©µÄsqlÓï¾ä¡£
SQL code:
select
b.pictureid as ͼƬ±àºÅ,a.newstitle as ÐÂÎűêÌâ,a.n ......