sqlÖеÄÆÊÎöº¯ÊýÔõôÓÃ
ÆÊÎöº¯ÊýÊǶÔÊý¾Ý¼¯¾ÙÐÐÅÌËãµÄÌØÊ⺯Êý£¬ÓÃÓÚ°´ÐС¢·ÖÇø»ò´°¿ÚÆÊÎöÊý¾Ý¡£ÕâЩº¯Êý¿ÉÓÃÓÚ»ã×ÜÊý¾Ý£¨ÀýÈçÇóºÍ¡¢Çóƽ¾ùÖµ£©¡¢ÅÌËãÅÅÃûºÍ°Ù·Ö±È¡¢È·¶¨²î±ðºÍÇ÷ÊÆÒÔ¼°½¨ÉèÀÛ»ýÖµ¡£ÔÚ sql ÖÐʹÓÃÆÊÎöº¯Êý£¬ÐèҪѡÔñÊʵ±µÄº¯Êý¡¢Ö¸¶¨´°¿ÚºÍÌṩ²ÎÊý¡£³£¼ûÆÊÎöº¯Êý°üÀ¨ sum()¡¢avg()¡¢count()¡¢rank()¡¢moving_average() ºÍ stddev()¡£ÆÊÎöº¯Êý¿ÉÌá¸ßÐÔÄÜ¡¢¼ò»¯ÅÌÎʲ¢ÌṩǿʢµÄÆÊÎöÄÜÁ¦£¬ÉîÈëÑо¿Êý¾Ý¡£
SQL ÖеÄÆÊÎöº¯Êý£ºÈëÃÅÖ¸ÄÏ
ʲôÊÇÆÊÎöº¯Êý£¿
ÆÊÎöº¯ÊýÊǶÔÊý¾Ý¼¯ÖеÄÊý¾Ý¾ÙÐÐÅÌËãµÄÌØÊ⺯Êý£¬ÔÊÐíÓû§Æ¾Ö¤ÐС¢·ÖÇø»ò´°¿Ú¹æÄ£¶ÔÊý¾Ý¾ÙÐÐÆÊÎö¡£
ÆÊÎöº¯ÊýµÄ×÷ÓÃ
ÆÊÎöº¯ÊýÌṩÁËÇ¿Ê¢µÄ¹¦Ð§£¬°üÀ¨£º
¶ÔÊý¾Ý¾ÙÐлã×Ü£¨ÀýÈçÇóºÍ¡¢Çóƽ¾ùÖµ¡¢Çó¼ÆÊýµÈ£©
ÅÌËãÅÅÃûºÍ°Ù·Ö±È
È·¶¨ÐÐÖ®¼äµÄ²î±ðºÍÇ÷ÊÆ
½¨ÉèÀÛ»ýÖµ
ÔõÑùʹÓÃÆÊÎöº¯Êý
ÔÚ SQL ÖÐʹÓÃÆÊÎöº¯Êý£¬ÐèÒª×ñÕÕÒÔÏ°취£º
Ñ¡ÔñºÏÊʵĺ¯Êý£ºÈ·¶¨ÒªÖ´ÐеÄÆÊÎö²Ù×÷£¬ÀýÈçÇóºÍ¡¢Çóƽ¾ùÖµ»òÇóÅÅÃû¡£
Ö¸¶¨´°¿Ú£º½ç˵ÆÊÎöº¯ÊýµÄÓ¦ÓùæÄ£¡£¿ÉÒÔÊÇÐС¢·ÖÇø»ò´°¿Ú¡£
Ìṩ²ÎÊý£ºÌṩ±ØÐèµÄ²ÎÊý£¬ÀýÈçȺ¼¯º¯ÊýµÄ²ÎÊý»ò´°¿Úº¯ÊýµÄ×îÏȺͿ¢Ê½çÏß¡£
ʾÀý
ÒÔÏÂʾÀýÑÝʾÔõÑùʹÓà SUM() ÆÊÎöº¯ÊýÅÌËãÒ»ÁÐÖÐÖµµÄ×ܺͣº
SELECT SUM(salary) FROM employee;
µÇ¼ºó¸´ÖÆ
ÒÔÏÂʾÀýÑÝʾÔõÑùʹÓà RANK() ÆÊÎöº¯Êý¶Ôÿ¸ö²¿·ÖÄÚµÄÔ±¹¤¾ÙÐÐÅÅÃû£º
SELECT department_id, RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS rank FROM employee;
µÇ¼ºó¸´ÖÆ
ÆäËû³£¼ûÆÊÎöº¯Êý
ÒÔÏÂÊÇ SQL ÖÐÆäËûһЩ³£ÓõÄÆÊÎöº¯Êý£º
Çóƽ¾ùÖµ£ºAVG()
Çó¼ÆÊý£ºCOUNT()
Çó×î´óÖµ£ºMAX()
Çó×îСֵ£ºMIN()
ÅÌËãÒƶ¯Æ½¾ù£ºMOVING_AVERAGE()
ÅÌËã±ê×¼Îó²î£ºSTDDEV()
Óŵã
ʹÓÃÆÊÎöº¯ÊýÓÐÒÔÏÂÓŵ㣺
Ìá¸ßÐÔÄÜ£¬ÓÉÓÚÅÌËãÊÇÔÚÊý¾Ý¿âЧÀÍÆ÷ÉϾÙÐеġ£
¼ò»¯ÅÌÎÊ£¬ÓÉÓÚËüÏû³ýÁ˶Ô×ÓÅÌÎÊ»òÔÝʱ±íµÄÐèÒª¡£
ÌṩǿʢµÄÆÊÎöÄÜÁ¦£¬ÔÊÐíÓû§ÉîÈëÑо¿Êý¾Ý¡£
ÒÔÉϾÍÊÇsqlÖеÄÆÊÎöº¯ÊýÔõôÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡