¡¾×ª¡¿ sqlͳ¼Æ£¹ØÓÚѧÉú³É¼¨(´ð°¸)
sqlͳ¼Æ£¹ØÓÚѧÉú³É¼¨(´ð°¸)
http://blog.sina.com.cn/s/blog_61380b320100ej9p.html
´ð°¸£º
1. ¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select name,sum(score) as allscore from stuscore group by name order by allscore
2. ¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select distinct t1.name,t1.stuid,t2.allscore from stuscore t1,
(
select stuid,sum(score) as allscore from stuscore group by stuid
)t2
where t1.stuid=t2.stuid
order by t2.allscore desc
3. ¼ÆËãÿ¸öÈ˵¥¿ÆµÄ×î¸ß³É¼¨
select t1.stuid,t1.name,t1.subject,t1.score from stuscore t1,
(
select stuid,max(score) as maxscore from stuscore group by stuid
) t2
where t1.stuid=t2.stuid and t1.score=t2.maxscore
4.¼ÆËãÿ¸öÈËµÄÆ½¾ù³É¼¨
select distinct t1.stuid,t1.name,t2.avgscore from stuscore t1,
(
select stuid,avg(score) as avgscore from stuscore group by stuid
) t2
where t1.stuid=t2.stuid
5.Áгö¸÷Ãſγ̳ɼ¨×îºÃµÄѧÉú
select t1.stuid,t1.name,t1.subject,t2.maxscore from stuscore t1,
(
select subject,max(score) as maxscore from stuscore group by subject
) t2
where t1.subject=t2.subject and t1.score=t2.maxscore
6.Áгö¸÷Ãſγ̳ɼ¨×îºÃµÄÁ½Î»Ñ§Éú
select distinct t1.* from stuscore t1
where t1.stuid in
(select top 2 stuscore.stuid from stuscore where subject = t1.subject order by score desc)
order by t1.subject
7.ѧºÅ ÐÕÃû ÓïÎÄ Êýѧ Ó¢Óï ×Ü·Ö Æ½¾ù·Ö
select&nbs
Ïà¹ØÎĵµ£º
²»Åç¿ÚË®!Ö±½ÓÉÏͼ
1.Êý¾Ý¿â¶ÔÏó¼ìË÷¹¦ÄÜ
2.T-SQLÓï·¨°ïÖú
3.³£Óú¯Êý°ïÖú(²»¶®ÄñÓï?13×Ô¼ºÁ·Á·°É!)
Download Now
°²×°Á÷³Ì:
1.ÏȰÑÍøÂçßDzæÁË(¶ÏÍø - -!!)
2.°ÑËùÓеÄSQL Server,VS¶¼¹ØÁË,ÔËÐÐSQLPrompt 4.0.exe°²×°
3.°²×°Íê±Ïºó,Í˳öRedGate.SQLPrompt.TrayApp ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient; //ÒýÓÃÃüÃû¿Õ¼ä
namespace DAL
{
/*******************************************************************************
&n ......
SQL ServerȨÏÞ¹ÜÀí²ßÂÔ
Êý¾Ý¿â½¨Á¢Ö®ºó£¬Êý¾ÝµÄ°²È«¾ÍÏÔµÃÓÈÎªÖØÒª£¬¶ÔÓÚÒ»¸öÊý¾Ý¿â¹ÜÀíÔ±À´Ëµ£¬°²È«ÐÔ¾ÍÒâζ×ÅËû±ØÐë±£Ö¤ÄÇЩ¾ßÓÐÌØÊâÊý¾Ý·ÃÎÊȨÏÞµÄÓû§Äܹ»µÇ¼µ½SQL Server£¬²¢ÇÒÄܹ»·ÃÎÊÊý¾ÝÒÔ¼°¶ÔÊý¾Ý¿â¶ÔÏóʵʩ¸÷ÖÖȨÏÞ·¶Î§ÄڵIJÙ×÷£»Í¬Ê±£¬Ëû»¹Òª·ÀÖ¹ËùÓеķÇÊÚȨÓû§µÄ·Ç·¨²Ù×÷¡£Õý»ùÓÚ´Ë£¬SQL Server 2000ÌṩÁ ......
Sqlʱ¼äº¯Êý
Ò»¡¢sql serverÈÕÆÚʱ¼äº¯Êý
Sql ServerÖеÄÈÕÆÚÓëʱ¼äº¯Êý
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
Àý ......
sqlͳ¼Æ£¹ØÓÚѧÉú³É¼¨
http://blog.sina.com.cn/s/blog_61380b320100ej9k.html
sqlͳ¼Æ£¹ØÓÚѧÉú³É¼¨
ѧÉú³É¼¨±í(stuscore)£º
ÐÕÃû£ºname
¿Î³Ì£ºsubject
·ÖÊý£ºscore
ѧºÅ£ºstuid
ÕÅÈý
Êýѧ
89
1
ÕÅÈý
ÓïÎÄ
80
1
ÕÅÈý
Ó¢Óï
70
1
ÀîËÄ
Êýѧ
90
2
ÀîËÄ
ÓïÎÄ
70
2
ÀîËÄ
Ó¢Óï
......