Çó³¬ÄÑSQLÅúÁ¿´¦ÀíÓï¾ä£º ÏÈÅÅÐò£¬ÔÙ·Ö×é±àÂëµÄÎÊÌâ
ÓбíA£¬ÈçÏ£º
x y name ID sxm
300 500 a 1
301 501 b 2
302 502 c 3
303 503 d 4
304 504 a 5
305 505 b 6
306 506 c 7
307 507 d 8
308 508 a 9
309 509 b 10
310 510 c 11
311 511 d 12
312 512 a 13
313 513 b 14
314 514 c 15
315 515 d 16
316 516 a 17
317 517 b 18
318 518 c 19
319 519 d 20
320 520 a 21
Ï£ÍûµÃµ½µÄЧ¹û£º
£¨Ïȸù¾Ýname×ֶηÖ×飬Ȼºó°´y×ֶνµÐò£¬x×Ö¶ÎÉýÐò½øÐÐÅÅÐò£¬È»ºó¸÷¸ö·Ö×é´Ó1¿ªÊ¼µÝÔö±àÂ룬±àÂë·ÅÔÚsxm×ֶΣ©
Ч¹ûÈçÏ£º
x y name ID sxm
320 520 a 21 1
316 516 a 17 2
312 512 a 13 3
308 508 a 9 4
304 504 a 5 5
300 500 a 1 6
317 517 b 18 1
313 513 b 14 2
309 509 b 10 3
305 505 b 6 4
301 501 b 2 5
318 518 c 19 1
314 514 c 15 2
310 510 c 11 3
306 506 c 7 4
302 502 c 3 5
319 519 d 20 1
315 515 d 16 2
311 511 d 12 3
307 507 d 8 4
303 503 d 4 5
SQL code:
SELECT *,
(SELECT COUNT(*) from TB WHERE NAME=T.NAME AND ID>=T.ID)AS SXM
from TB T
ORDER BY (SELECT COUNT(*) from TB WHERE NAME=T.NAME AND ID>=T.ID),NAME, ID DESC
ÊÔÊÔ¿´
SQL code
Code highlighting produc
Ïà¹ØÎÊ´ð£º
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεĻ°¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
PL/SQLÀïÃæµÄTABLE---¡·QUERY½çÃæ
ÓÐSQL|OUTPUT|STATISTICSÈý¸öÒ³Ãæ
ΪʲôÎÒÔÚSQLÀïÃæÓÃSELECTÓï¾ä»òÕßUPDATEºó£¬OUTPUTºÍSTATISTICSÒ³Ã涼ûÈκÎÊý¾Ý£¿
ÊÇҪʲôÇé¿öÏ£¬Õâ2¸öÒ³ÃæÒ²»áÓÐÊý¾Ý ......
ÔÚÏÈ°²×°ÁËvs.net 2008 ºóÔõô°²×° Sql server 2005¡£ËÑÁ˺ܶàÎÄÕ£¬¿ÉÊÇ»¹ÊÇûÓп´µ½Ôõô²ÅÄܹ»°²×°ÉÏ¡£
×ÜÊÇÔÚ°²×°sql serverµÄ¿Í»§¶Ë£¨management studio£©Ê±ºò±¨´í£¬×°ÄǸöÊý¾Ý¿â server ÒýÇæµÄʱºòûÓÐÎ ......
¶ÔÏó×ÊÔ´¹ÜÀíÆ÷À¶Ôijһ¸ö±í£¬Èç¹ûÓÒ¼üÑ¡Ôñ¡°Ñ¡ÔñÇ°1000ÐС±Ó¦¸Ã²»Ëø±íÊÇ°É
Èç¹ûÑ¡Ôñ¡°±à¼Ç°200ÐС±£¬ÊDz»ÊÇ»áËø±í¶øµ¼Ö±ðµÄÈ˲»ÄܽøÈë±à¼ÕâÕÅ±í£¿
Èç¹ûн¨Ò»¸ö²éѯ´°¿Ú£¬ÓÃsqlÓï¾äÀ´²Ù×÷£¬ÊDz»ÊǾͲ»´æ ......
sql 2008ÖÐР¸½¼ÓµÄÊý¾Ý¿â£¬ÈçºÎÓÃDDLÓïÑÔÌí¼Ó¡°ËùÓÐÕß¡±£»
ÊÖ¶¯µÄ·½Ê½Îª£ºÊó±êÔÚи½¼ÓµÄÊý¾Ý¿âÉÏÓÒ¼ü——>ÊôÐÔ——>Îļþ——>ËùÓÐÕߣ¬È»ºóÓұ߿հ׼üÑ¡Ôñ£»
DDLÓï¾ ......