sql ²éѯ³öÀ´Ò»¸ö±íÔÚ²åÈëµ½ÁíÒ»¸ö±íÀï
ALTER FUNCTION [dbo].[fun_tongji]()
RETURNS @t1 table (
yue int ,
money int
)
AS
begin
Declare @i int
set @i=1
-- declare @t1 table (
-- yue int ,
-- money int
-- )
while (@i<=12)
begin
INSERT into @t1 (yue,money) select isnull(sum(money),0) as money,@i as yue from zhangbenjilu where datepart(month,usedatetime)=@i
set @i=@i+1
end
return ;
end
Ïà¹ØÎĵµ£º
Íâ¼ü
======================
Íâ¼üÊÇÏà¶ÔÓÚÖ÷¼ü˵µÄ£¬Êǽ¨Á¢±íÖ®¼ä µÄÁªÏµµÄ±ØÐëµÄǰÌá¡£
±ÈÈ磺ѧÉú±í ¡¢Ñ§Éú³É¼¨±íÒ»Ò»¶ÔÓ¦ÊÇÒòΪ ËûÃǶ¼¾ßÓÐÏàͬµÄ×ֶΣºÑ§ºÅ£¬°ÑѧÉú±í×÷ΪÖ÷±í£¬Ñ§ºÅÊÇËûµÄÖ÷¼ü£¬Ïà¶ÔÓÚÖ÷±íÀ´Ëµ£¬Ñ§Éú³É¼¨µÄ×ֶΠѧºÅ¾ÍÊÇѧÉú±íµÄÍâ¼ü¡£
ûÓÐÍâ¼ü£¬Á½¸ö±í¾Íû°ì·¨½¨Á¢ÁªÏµ°¡£¡ ......
£¨1£©
Mcirosoft JET SQL ÖУ¬ÈÕÆÚÓÑ#’¶¨½ç¡£ÈÕÆÚÒ²¿ÉÒÔÓÃDatevalue()º¯ÊýÀ´´úÌæ¡£ÔڱȽÏ×Ö·ûÐ͵ÄÊý¾Ýʱ£¬Òª¼ÓÉϵ¥ÒýºÅ’’£¬Î²¿Õ¸ñÔڱȽÏÖб»ºöÂÔ¡£
Àý£º
WHERE OrderDate>#96-1-1#
Ò²¿ÉÒÔ±íʾΪ£º
WHERE OrderDate>Datevalue(‘1/1/96’)
ʹÓà NOT ±í´ïʽÇó·´¡£
Àý£ ......
ORACLE ÖÐSQL Óï¾ä´óÖ¿ÉÒÔ·ÖΪ4´óÀà
1.DQL£¨data quary language Êý¾Ý²éѯÓïÑÔ£©
Êý¾Ý²éѯÓïÑÔDQL»ù±¾½á¹¹ÊÇÓÉSELECT×Ӿ䣬from×Ӿ䣬WHERE×Ó¾ä×é³É
2.DDL£¨data definition language Êý¾Ý¶¨ÒåÓïÑÔ£©
CREATE
ALTER
DROP
RENAME
TRUNCATE
3.DML£¨data manipulation language Êý¾Ý²Ù×ÝÓïÑÔ£©
INSERT
UPDATE
......
·ÀÖ¹·Ç·¨±íD99_Tmp,kill_kkµÄ³öÏÖÊÇ·ÀÖ¹ÎÒÃǵÄÍøÕ¾²»±»¹¥»÷,ͬʱҲÊÇSQL°²È«·À·¶Ò»µÀ±ØÒªµÄ·ÀÏß,Ëä˵ÀûÓÃÕâÖÖ·½Ê½¹¥»÷µÄÈ˶¼ÊǺڿÍÖеÄСÄñ,µ«ÊÇÎÒÃÇÒ²²»µÃ²»·À,ÒÔÃâÔì³É²»¿ÉÏëÏóµÄºó¹û,·Ï»°²»¶à˵ÁË,˵Ï·À·¶·½·¨:
xp_cmdshell¿ÉÒÔÈÃϵͳ¹ÜÀíÔ±ÒÔ²Ù×÷ϵͳÃüÁîÐнâÊÍÆ÷µÄ·½Ê½Ö´Ðиø¶¨µÄÃüÁî×Ö·û´®,²¢ÒÔÎı¾Ðз½Ê½·µ»ØÈκÎÊ ......
¶¨Ò庯Êý
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[FunJSLC](@carid bigint,@date datetime)
returns decimal
as
begin
declare @jslc decimal
set @jslc=(select JSLC from BYReMIn where iCarID=@carid and dtDate=@date)
return(@jslc)
end
´æ´¢¹ý³ÌÓ¦Óú¯Êý
set ANSI_NULLS ......