sqlÓï¾ä°ÂÃîÖ®Ò»
ÀýÈçÎÊÌ⣺ÏÖÔÚÄãÃæ¶ÔÒ»Õűí table1 , table1ÖÐÓиö×Ö¶ÎΪsales_salary £¬ÔÚÊý¾Ý¿â´æ·ÅµÄ×Ö¶ÎΪint ÀàÐÍ ¡£
ÒªÇó£¬Äãͳ¼ÆµÄ½á¹ûµ¥Î»£¨ÍòÔª£©£¬±£Áô2λСÊý¡£²¢ÇÒ»áÓÐÕâÑùµÄµÈʽ £¨1ÐУ«2ÐУ½3ÐУ½7ÐУ«8ÐУ© Ãæ¶ÔÕâÑùµÄÎÊÌ⣬½â¾öµÄ·½°¸Óкܶࡣ±ÈÈ磬Äã¿ÉÒÔͨ¹ýÊÓͼµÄ·½°¸À´½â¾ö£¬»ò¿ØÖÆÊäÈëÓò ...
µ«ÓÐÒ»ÖÖµÈЧ¿ØÖÆÊäÈëÓòµÄ°ì·¨£¬ÄǾÍÊÇдsqlÓï¾ä¡£
ÕâÐèÒª¶Ô sql Óï¾äºÜ¾«Í¨£¬¶®µÄÆäÖеÄÄÚº¡£
ex1:
select sales_date ,sum(round(sales_salary/10000,2))
from table1
group by sales_date ;
ex2:
select t.sales_date,sum(t.sales_salary) from (
select sales_date,round(sales_salary/10000,2) as sales_salary from table1
) t
group by t.sales_date;
ex1Óëex2ÊÇÊâ;ͬ¹éµÄÒ»ÖÖЧ¹û£¬µ«ÊÇЧÂÊÊDz»Ò»ÑùµÄ¡£
ËùÒÔsqlÓï¾äµÄ»ù±¾¹Ø¼ü¾äÐͺܼòµ¥ select ... from ... where .....group by ...having .....order by ....£¬µ«¼òµ¥µÄ¶«Î÷ºÜÄÑÕÆÎÕ¡£
Ï£ÍûÄܶÔѧϰsqlÓïÑÔµÄÅóÓÑÓÐËù°ïÖú¡£
Ïà¹ØÎĵµ£º
±È½ÏÁ½¸öSQLµÄÖ´ÐÐʱ¼ä
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PROC_SQL_COMP]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[PROC_SQL_COMP]
GO
/*--²âÊÔÁ½×éSQLµÄƽ¾ùʱ¼ä
ÀûÓÃosql.exeÀ´²âÊÔÁ½×é SQL Óï¾äµÄÖ´ÐÐʱ¼ä
²âÊԵĴ洢¹ý³ ......
ÄãÊÇ·ñÔÚǧ·½°Ù¼ÆÓÅ»¯SQL Server Êý¾Ý¿âµÄÐÔÄÜ?Èç¹ûÄãµÄÊý¾Ý¿âÖк¬ÓдóÁ¿µÄ±í¸ñ£¬°ÑÕâЩ±í¸ñ·ÖÇø·ÅÈë¶ÀÁ¢µÄÎļþ×é¿ÉÄÜ»áÈÃÄãÊÜÒæ·Ëdz¡£SQL Server 2005ÒýÈëµÄ±í·ÖÇø¼¼Êõ£¬ÈÃÓû§Äܹ»°ÑÊý¾Ý·ÖÉ¢´æ·Åµ½²»Í¬µÄÎïÀí´ÅÅÌÖУ¬Ìá¸ßÕâЩ´ÅÅ̵IJ¢Ðд¦ÀíÐÔÄÜÒÔÓÅ»¯²éѯÐÔÄÜ¡£
¡¡¡¡SQL ServerÊý¾Ý¿â±í·ÖÇø²Ù×÷¹ý³ÌÓÉÈý¸ö²½Öè×é³É£º
¡ ......
sql isnullº¯ÊýµÄʹÓÃ
ISNULL
ʹÓÃÖ¸¶¨µÄÌæ»»ÖµÌæ»» NULL¡£
Óï·¨
ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_value
ÔÚ check_expression Ϊ NULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë chec ......