¼¸µÀ¾µäµÄSQL±ÊÊÔÌâÄ¿
¼¸µÀ¾µäµÄSQL±ÊÊÔÌâÄ¿£¨Óд𰸣©
£¨1£©±íÃû£º¹ºÎïÐÅÏ¢
¹ºÎïÈË ÉÌÆ·Ãû³Æ ÊýÁ¿
A ¼× 2
B ÒÒ 4
C ±û 1
A ¶¡ 2
B ±û 5
……
£¨ÆäËûÓû§ÊµÑéµÄ¼Ç¼´ó¼Ò¿É×ÔÐвåÈ룩
¸ø³öËùÓйºÈëÉÌƷΪÁ½ÖÖ»òÁ½ÖÖÒÔÉϵĹºÎïÈ˼Ǽ
´ð£ºselect * from ¹ºÎïÐÅÏ¢ where ¹ºÎïÈË in (select ¹ºÎïÈË from ¹ºÎïÐÅÏ¢ group by ¹ºÎïÈË having count(*) >= 2);
£¨2£©±íÃû£º³É¼¨±í
ÐÕÃû ¿Î³Ì ·ÖÊý
ÕÅÈý ÓïÎÄ 81
ÕÅÈý Êýѧ 75
ÀîËÄ ÓïÎÄ 56
ÀîËÄ Êýѧ 90
ÍõÎå ÓïÎÄ 81
ÍõÎå Êýѧ 100
ÍõÎå Ó¢Óï 49
……
£¨ÆäËûÓû§ÊµÑéµÄ¼Ç¼´ó¼Ò¿É×ÔÐвåÈ룩
¸ø³ö³É¼¨È«²¿ºÏ¸ñµÄѧÉúÐÅÏ¢£¨°üº¬ÐÕÃû¡¢¿Î³Ì¡¢·ÖÊý£©£¬×¢£º·ÖÊýÔÚ60ÒÔÉÏÆÀΪºÏ¸ñ
´ð£ºselect * from ³É¼¨±í where ÐÕÃû not in (select distinct ÐÕÃû from ³É¼¨±í where ·ÖÊý < 60)
»òÕߣº
select * from ³É¼¨±í where ÐÕÃû in (select ÐÕÃû from ³É¼¨±í group by ÐÕÃû having min(·ÖÊý) >=60)
£¨3£©±íÃû£ºÉÌÆ·±í
Ãû³Æ ²úµØ ½ø¼Û
Æ»¹û ÑĮ̀ 2.5
Æ»¹û ÔÆÄÏ 1.9
Æ»¹û ËÄ´¨
Ïà¹ØÎĵµ£º
½éÉÜ
ͨ³££¬Ñз¢ÈËԱʹÓõÄÊÇT-SQLÀ´´´½¨SQL ServerµÄ´æ´¢¹ý³Ì¡¢º¯ÊýºÍ´¥·¢Æ÷¡£ ¶øÏÖÔÚµÄSQL Server 2005ÒÑÍêÈ«Ö§³Ö.NETͨÓÃÓïÑÔÔËÐÐʱ£¨CLR£©ÁË¡£ Õâ¾ÍÒâζ×Å£¬ÄúÄܹ»Ê¹ÓÃ.NETµÄÓïÑÔ£¬ÈçC#¡¢VB.NETÖ®ÀàµÄÀ´Ñз¢SQL ServerµÄ´æ´¢¹ý³Ì¡¢º¯ÊýºÍ´¥·¢Æ÷¡£ SQL Server ºÍ CLR µÄ¼¯³É¸øÎÒÃÇ´øÀ´ÁËn¶àºÃ´¦£¬Èçʵʱ±àÒë¡¢ÀàÐÍ°²È«¡ ......
Àý×Ó£º int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
public static string replace(string str, string str2)
{
str = str.Replace(";", str2);
str = ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE data ......
½ñÌìÁ·Ï°ÔÚJSPÒ³ÃæÖÐʵÏÖ·ÖҳЧ¹û£¬ÔÚ²éѯÓï¾ä·½ÃæÇ£³¶µ½ÁËtopµÄÓ÷¨¡£¼òÒª×öÒ»ÏÂ×ܽ᣺
ΪʵÏÖÀàËÆtopµÄ¹¦ÄÜ£¬ÎÒÃÇÔÚSQL ServerÖкÍMySQLÖÐʹÓõ½µÄSQLÓï¾äÊDz»Í¬µÄ¡£
1¡¢ÔÚSQL ServerÖУ¬ÎÒÃÇʹÓà select top N * ......
֮ǰżȻ¹äÍøÒ³µÄʱºò¿´µ½µÄ,ÏêϸµÄÍøÖ·Íü¼Çcopy¹ýÀ´ÁË£¬ÕæÊDZ§Ç¸¡£¾õµÃ¼òµ¥Ò׶®,ËùÒÔתÁË,ÎûÎû
ÓйطÖÒ³ SQL µÄ×ÊÁϺܶ࣬ÓеÄʹÓô洢¹ý³Ì£¬ÓеÄʹÓÃÓαꡣ±¾È˲»Ï²»¶Ê¹ÓÃÓα꣬ÎÒ¾õµÃËüºÄ×Ê¡¢Ð§Âʵͣ»Ê¹Óô洢¹ý³ÌÊǸö²»´íµÄÑ¡Ôñ£¬ÒòΪ´æ´¢¹ý³ÌÊǾ¹ýÔ¤±àÒëµÄ£¬Ö´ÐÐЧÂʸߣ¬Ò²¸üÁé»î¡£ÏÈ¿´¿´µ¥Ìõ SQL Óï¾äµÄ·ÖÒ³ SQL ......