SQL Êý¾Ý¿âÖ®Ò»
1. SELECT
ʵÀý105
SELECT ID "±àºÅ",Name ÐÕÃû,
Math_Score 'Êýѧ³É¼¨', //ÔõôÓеÄÓÐAS,ÓеÄûÓÐ
Music_Score AS ÒôÀֳɼ¨,
English_Score AS Ó¢Îijɼ¨
from tb_StuScore
SELECT ±àºÅ, ÉÌÆ·Ãû³Æ,ÊýÁ¿,µ¥¼Û,½ø¼Û,
(µ¥¼Û*ÊýÁ¿) AS ÏúÊÛ¶î,
(µ¥¼Û*ÊýÁ¿-½ø¼Û*ÊýÁ¿) AS ÀûÈó
from tb_xsb
SELECT ID,Name,Math_Score,Music_Score,EngLish_Score
from tb_StuScore
WHERE NOT (EngLish_Score>= 90) OR (Math_Score>=95)
SELECT *
from tb_StuScore
WHERE Math_score LIKE '8_'
SELECT *
from tb_StuScore
WHERE Name LIKE 'Áõ%'
SELECT *
from tb_StuScore
WHERE English_score LIKE '9[5-9]%'
SELECT *
from tb_StuScore
WHERE Math_Score LIKE '[^9][0-9]'
SELECT *
from tb_StuScore
WHERE (Name LIKE 'Áõ%')
AND (
(Math_Score LIKE '[^7]_')
OR (EngLish_score LIKE '9[0-9]')
)
SELECT 'ÐÕÃû£º'+ Name + '£»±àºÅ£º'+
CONVERT(varchar(3),id) AS ѧÉúÐÅÏ¢
from tb_StuScore
SELECT ÐÕÃû,LTRIM(ÐÕÃû) AS È¥³ý×óÃæ¿Õ¸ñ,
RTRIM(ÐÕÃû) AS È¥³ýÓÒÃæ¿Õ¸ñ,
LTRIM(RTRIM(ÐÕÃû)) AS È¥³ý×óÓÒ¿Õ¸ñ
from ¿Í»§ÐÅÏ¢±í
SELECT *
from tb_StuScore
WHERE Music_Score IN (85,95,100)
SELECT *
from tb_StuScore
WHERE Music_Score NOT IN (85,95,100)
SELECT *
from tb_StuScore
WHERE Music_Score > ALL
( SELECT Music_Score
from tb_StuScore
WHER
Ïà¹ØÎĵµ£º
1¡¢ÎļþºÍÎļþ×éµÄº¬ÒåÓë¹Øϵ
ÿ¸öÊý¾Ý¿âÓÐÒ»¸öÖ÷Êý¾ÝÎļþ.ºÍÈô¸É¸ö´ÓÎļþ¡£ÎļþÊÇÊý¾Ý¿âµÄÎïÀíÌåÏÖ¡£ Îļþ×é¿ÉÒÔ°üÀ¨·Ö²¼ÔÚ¶à¸öÂß¼·ÖÇøµÄÎļþ£¬ÊµÏÖ¸ºÔØƽºâ¡£Îļþ×éÔÊÐí¶ÔÎļþ½øÐзÖ×飬ÒÔ±ãÓÚ¹ÜÀíºÍÊý¾ÝµÄ·ÖÅ䣯·ÅÖá£ÀýÈ磬¿ÉÒÔ·Ö±ðÔÚÈý¸öÓ²ÅÌÇý¶¯Æ÷ÉÏ´´½¨Èý¸öÎļþ£¨Data1.ndf¡¢Data2.ndf&nb ......
¼ÙÈçÄãд¹ýºÜ¶à³ÌÐò£¬Äã¿ÉÄÜż¶û»áÅöµ½ÒªÈ·¶¨×Ö·û»ò×Ö·û´Ü´®·ñ°üº¬ÔÚÒ»¶ÎÎÄ×ÖÖУ¬ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«ÌÖÂÛʹÓÃCHARINDEXºÍPATINDEXº¯ÊýÀ´ËÑË÷ÎÄ×ÖÁкÍ×Ö·û´®¡£ÎÒ½«¸æËßÄãÕâÁ½¸öº¯ÊýÊÇÈçºÎÔËתµÄ£¬½âÊÍËûÃǵÄÇø±ð¡£Í¬Ê±ÌṩһЩÀý×Ó£¬Í¨¹ýÕâЩÀý×Ó£¬Äã¿ÉÒÔ¿ÉÒÔ¿¼ÂÇʹÓÃÕâÁ½¸öº¯ÊýÀ´½â¾öºÜ¶à²»Í¬µÄ×Ö·ûËÑË÷µÄÎÊÌâ¡£
&nb ......
ÓÃPL/SQL Deleveloperµ¼³öcsvÎļþ¸ñʽÊý¾Ý£¬ÓÃexcel´ò¿ªÊÇÂÒÂ룬ÓüÇʱ¾´ò¿ªÕý³££¬Ôõô»ØÊ£¿
ÂíÉÏGoogle£¬ÔÀ´µ¼³öµÄÎļþµÄ±àÂë¸ñʽÊÇUTF-8ºÍ¶øexcelĬÈÏ´ò¿ªÎļþµÄ±àÂëÊÇunicode£¬ÓÚÊÇ£º
1¡¢ÓüÇʱ¾´ò¿ªÎļþ£¬È»ºóÁí´æΪ£¬ÌîдÎļþÃû£¬Ñ¡Ôñ±àÂë¸ñʽΪunicode
2¡¢ÓÃexcel´ò¿ªÐµÄÎļþ£¬Õý³£ÏÔʾ
µ«ÊdzöÏÖÁíÍâµÄÎÊÌ⣠......
£¨18£©ÓÃEXISTSÌæ»»DISTINCT£º
µ±Ìá½»Ò»¸ö°üº¬Ò»¶Ô¶à±íÐÅÏ¢(±ÈÈ粿ÃűíºÍ¹ÍÔ±±í)µÄ²éѯʱ,±ÜÃâÔÚSELECT×Ó¾äÖÐʹÓÃDISTINCT¡£Ò»°ã¿ÉÒÔ¿¼ÂÇÓÃEXISTÌæ»», EXISTS ʹ²éѯ¸üΪѸËÙ,ÒòΪRDBMSºËÐÄÄ£¿é½«ÔÚ×Ó²éѯµÄÌõ¼þÒ»µ©Âú×ãºó,Á¢¿Ì·µ»Ø½á¹û¡£Àý×Ó£º
(µÍЧ):
SELECT DISTINCT DEPT_NO,DEPT_NAME  ......