SQL Server ÃæÊÔÌâ
Sql³£¼ûÃæÊÔÌ⣨×ܽᣩ
0.ÈçºÎɾ³ýÒ»¸öÓµÓбȽ϶àµÄÊý¾ÝµÄ±í
Èç¹û¸Ã±íËùÔÚµÄÊý¾Ý¿âÓµÓнÏÉÙµÄ±í£¬¿ÉÒÔÏȽ«ÆäÓà±íµ¼³öÈ¥£¬È»ºó·ÖÀëÊý¾Ý¿â£¬ÔÚɾ³ý£¬Ð½¨Ò»¸öͬÃûÊý¾Ý¿â£¬½«ÆäÓà±íÔٴε¼Èë¡£
1.ÓÃÒ»ÌõSQLÓï¾ä ²éѯ³öÿÃſζ¼´óÓÚ80·ÖµÄѧÉúÐÕÃû
name kecheng fenshu
ÕÅÈý ÓïÎÄ 81
ÕÅÈý Êýѧ 75
ÀîËÄ ÓïÎÄ 76
ÀîËÄ Êýѧ 90
ÍõÎå ÓïÎÄ 81
ÍõÎå Êýѧ 100
ÍõÎå Ó¢Óï 90
A: select distinct name from table where name not in (select distinct name from table where fenshu<=80)
2.ѧÉú±í ÈçÏÂ:
×Ô¶¯±àºÅ ѧºÅ ÐÕÃû ¿Î³Ì±àºÅ ¿Î³ÌÃû³Æ ·ÖÊý
1 2005001 ÕÅÈý 0001 Êýѧ 69
2 2005002 ÀîËÄ 0001 Êýѧ 89
3 2005001 ÕÅÈý 0001 Êýѧ 69
ɾ³ý³ýÁË×Ô¶¯±àºÅ²»Í¬,ÆäËû¶¼ÏàͬµÄѧÉúÈßÓàÐÅÏ¢
A: delete tablename where ×Ô¶¯±àºÅ not in(select min(×Ô¶¯±àºÅ) from tablename group by ѧºÅ,ÐÕÃû,¿Î³Ì±àºÅ,¿Î³ÌÃû³Æ,·ÖÊý)
Ò»¸ö½ÐdepartmentµÄ±í£¬ÀïÃæÖ»ÓÐÒ»¸ö×Ö¶Îname,Ò»¹²ÓÐ4Ìõ¼Í¼£¬·Ö±ðÊÇa,b,c,d,¶ÔÓ¦ËĸöÇò¶Ô£¬ÏÖÔÚËĸöÇò¶Ô½øÐбÈÈü£¬ÓÃÒ»ÌõsqlÓï¾äÏÔʾËùÓпÉÄܵıÈÈü×éºÏ.
ÄãÏÈ°´Äã×Ô¼ºµÄÏë·¨×öһϣ¬¿´½á¹ûÓÐÎÒµÄÕâ¸ö¼òµ¥Âð£¿
´ð£ºselect a.name, b.name
from team a, team b
where a.name < b.name
ÇëÓÃSQLÓï¾äʵÏÖ£º´ÓTestDBÊý¾Ý±íÖвéѯ³öËùÓÐÔ·ݵķ¢Éú¶î¶¼±È101¿ÆÄ¿ÏàÓ¦Ô·ݵķ¢Éú¶î¸ßµÄ¿ÆÄ¿¡£Çë×¢Ò⣺TestDBÖÐÓкܶà¿ÆÄ¿£¬¶¼ÓÐ1£12Ô·ݵķ¢Éú¶î¡£
AccID£º¿ÆÄ¿´úÂ룬Occmonth£º·¢Éú¶îÔ·ݣ¬DebitOccur£º·¢Éú¶î¡£
Êý¾Ý¿âÃû£ºJcyAudit£¬Êý¾Ý¼¯£ºSelect * from TestDB
´ð£ºselect a.*
from TestDB a
,(select Occmonth,max(DebitOccur) Debit101ccur from TestDB where AccID='101' group by Occmonth) b
where a.Occmonth=b.Occmonth and a.DebitOccur>b.Debit101ccur
***********************************
Ïà¹ØÎĵµ£º
SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓã¨ËÄ£©
×÷Õߣºfreedk
Ò»¡¢ÉîÈëdz³öÀí½âË÷Òý½á¹¹
¶þ¡¢¸ÄÉÆSQLÓï¾ä
Èý¡¢ÊµÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì
¾Û¼¯Ë÷ÒýµÄÖØÒªÐÔºÍÈçºÎÑ¡Ôñ¾Û¼¯Ë÷Òý
¡¡¡¡ÔÚÉÏÒ»½ÚµÄ±êÌâÖУ¬±ÊÕßдµÄÊÇ£ºÊµÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì¡£ÕâÊÇÒòΪÔÚ½«±¾´æ´¢¹ý³ÌÓ¦ÓÃÓÚ“°ì ......
4.6 ͨ¹ýÈÕÖ¾²é¿´·þÎñÆ÷µÄÔËÐÐÇé¿ö
SQL Server 2005¿ÉÒÔ½«Ä³Ð©ÏµÍ³Ê¼þºÍÓû§×Ô¶¨ÒåµÄʼþ¼Ç¼µ½SQL Server´íÎóÈÕÖ¾ºÍWindowsÓ¦ÓóÌÐòÈÕÖ¾ÖС£ÕâÁ½ÖÖÈÕÖ¾¶¼»á×Ô¶¯±êÉÏʱ¼ä¡£
4.6.1 ÔÚ¡¾Ê¼þ²é¿´Æ÷¡¿Öв鿴·þÎñÆ÷µÄÔËÐÐÇé¿ö
SQL Server 2005·þÎñÆ÷µÄÆô¶¯¡¢¹Ø±ÕºÍÔÝÍ£¶¯×÷£¬¶¼»á²úÉúÒ»¸öʼþ¼Ç¼£¬Õâ¸ö¼Ç¼½«»á¼ÇÔÚWindows ......
JAVA£×Ö·û´®¹ýÂËÀà
package cn.com.hbivt.util;
/**
* Title:
*
* Description:
*
* Copyright: Copyright (c) 2005
*
* Company:
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
......
Ò».Êý¾Ý¿ØÖÆÓï¾ä (DML) ²¿·Ö
1.Insert (ÍùÊý¾Ý±íÀï²åÈë¼Ç¼µÄÓï¾ä)
Insert INTO ±íÃû(×Ö¶ÎÃû1, ×Ö¶ÎÃû2, ……) VALUES ( Öµ1, Öµ2, ……);
&nb ......
Ò».Îı¾µ¼ÈëÊý¾Ý¿â
--²½Öè1.´´½¨¿ØÖÆÎļþ
load data¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ --1¡¢¿ØÖÆÎļþ±êʶ
infile 'E:\oradata\orcl\test\inf_user.txt'¡¡¡¡¡¡¡¡¡¡¡¡¡¡ --2¡¢ÒªÊäÈëµÄÊý¾ÝÎļþÃûΪinf_user.txt (Îļþȱʡ·Åµ½C:\ Ï£¬Èç¹û²»ÊÇ£¬¾ÍÐèÒªÖ¸Ã÷ȫ·¾¶)
append into table inf_user¡¡¡¡¡¡¡¡--3¡¢Ïò±ítestÖÐ× ......