¹ØÓÚSQL avg СÊýµãλÊýµÄ½ØÈ¡
ÔÚÈ¡Ò»¸öƽ¾ùÖµµÄʱºòÍùÍùÓöµ½Ð¡ÊýµãλÊýµÄ½ØÈ¡¡£
Ç°¼¸ÌìÓöµ½¹ýÕâô¸öÎÊÌ⣬ÔÚKingDee EAS µÄ²éѯ·ÖÎöÆ÷ÀïÃæÈç¹ûÇóijһÎïÁϵÄƽ¾ùµ¥¼ÛʱÎÒÕâÑùдµÀ£º
select avg = case sum(bentry.FQuantity) when 0 then 0 else (sum(bentry.famount)/sum(bentry.FQuantity)) end,
´ËÓï¾ä¿´ËÆûʲôÎÊÌ⣬±Ï¾¹ÊÇÇóƽ¾ùÖµ£¬¿ÉÊÇÈç¹ûÒªÔÚÒ³ÃæÏÔʾСÊýµãºóÁ½Î»Ê±ÒªÔõô×öÄØ£¿´Ë±¨±í²»ÊÇBIÑùʽ£¬¾ÍÔÚsqlÖÐÈçºÎʵÏÖ£¿
Õý³£Çé¿öÏ¿ÉÒÔ¿¼ÂǵĽâ¾ö·½°¸Óɺܶ࣬È磺
cast( Round(A.iPrice,2) as varchar(50)) AS µ¥¼Û
cast( Round(A.iPrice,0,1) as varchar(50)) AS µ¥¼Û
cast(0.329999999999999 as numeric(5,2)»òÕßdecimal)
µ«ÊǺܱ§Ç¸ KingDee EAS 6.0 ÀïÃæÎÒ·¢ÏÖ²»ÄÜʹÓà cast ,round ,¶øcast *******
as numberic /decimal ¾Í¸ü²»ÄÜÓÃÁË¡£
»¹¿ÉÒÔ¿¼ÂÇsubsting()º¯Êý£¬concat()º¯ÊýÖ®ÀàµÄ¡£ºóÀ´·¢ÏÖOracle DB ÀïÃæÓиö¹Ø¼üÐԵĺ¯Êý£º
charindexºÜ¹ÜÓÃÓÚÊÇдÁ˶ÎsqlÈçÏ£º
avg = case charindex('.',"tableName.avgprice ) when 0 then tableName.avgprice else substring(tableName.avgprice,0,charindex('.',tableName.avgprice)+2) end
Èç¹ûƽ¾ùֵΪÕûÊý¶øûÓÐ'.'´æÔÚʱҲÄܺܺõĽâ¾ö¡£Õâ¾ÍÊÇ´îÅäcase ºÍcharindexµÄ×÷ÓÃÓںô¦£¡
ΪÁË·½±ã¶ÔÕâÒ»SQL½øÐÐÁËÕûÀí¡£
/**
* ½ØȡСÊýµãºóÁ½Î»
* @author Kobe Bryant24
* @param strsql
* @param tableName
* @return
*/
protected String filtrateFloatValue(String strsql,String tableName){
return strsql+"=case charindex('.'," +
tableName+"."+strsql+") when 0 then " +
tableName+"."+strsql+" else substring(" +
tableName+"."+strsql+",0,charindex('.'," +
tableName+"."+strsql+")+2) end" ;
}
Ïà¹ØÎĵµ£º
·½·¨Ò»£ºÊ¹ÓÃÓαê
declare @ProductName nvarchar(50)
declare pcurr cursor for select ProductName from Products
open pcurr
fetch next from pcurr into @ProductName
while (@@fetch_status = 0)
begin
print (@ProductName)
fetch next from pcurr into @ProductName
end
close pcurr
deallocate pcurr ......
¡¾×ª¡¿http://space.cnblogs.com/group/topic/33473/
http://www.cnblogs.com/ghd258/archive/2005/10/24/260836.html
Èç¹ûÔÚSQL Server ÀïÐèÒª¶¨Ê±»òÕßÿ¸ôÒ»¶Îʱ¼äÖ´ÐÐij¸ö´æ´¢¹ý³Ì»ò3200×Ö·ûÒÔÄÚµÄSQLÓï¾äʱ,¿ÉÒÔÓùÜÀí->SQL Server´úÀí->×÷ÒµÀ´ÊµÏÖ¡£
¡¡¡¡1¡¢¹ÜÀí->SQL Server´ú ......
Ê×ÏȾÍÊÇÒª×Ô¼º±àдһ¶Î´úÂ룬´æΪ.stx
Îļþ£¨ÀýÈçsql.stx£©£¬È»ºóÔÚeditplusµÄ²Ëµ¥À¸Tools->Configure User
Tools->Files->Setting &syntax,µãadd°´Å¥£¬ÔÚdescriptionÀ¸Î»ÌîÉÏsql,file
ExtensionsÀ¸Î»Ò²ÌîÉÏsql,Èç¹ûÓжà¸öÀ©Õ¹Ãû£¬Ö®¼äÓÓ£»”¸ô¿ª£¨ÀýÈ磺sql;db2£©,È»ºóÔÚsyntax
fileÀ¸Î»ÌîÉ ......
¡¡¡¡¶ÔÓÚOracleµÄµÚÈý·½¿ª·¢¹¤¾ß£¬±¾ÈËÖÓ°®ÓÚQuest SQL Navigator 5.5£¬ÒòΪËü·´Ó¦Ñ¸ËÙ¡¢Ö§³Ö¶à¸öÕ˺ÅͬʱµÇ¼£¬Æ½Ê±Ê¹ÓÃÆðÀ´ºÜ·½±ã¡£
¡¡¡¡²»¹ý£¬·¢ÏÖËüÓиöȱµã£¬¾ÍÊÇÒ»²éѯ´óµãµÄ±í£¬CPU¾ÍÕ¼ÓÃ50%ÒÔÉÏ£¬¸ãµ½Îҵı¾±¾¿ñ½Ð£¬ÎÒÕæÊܲ»ÁË¡£
¡¡¡¡µ½Ëü¹ÙÍø£¬·¢ÏÖÓÐа汾6.2ÁË£¬²»¹ýÏÂÔØҪע²áʲôµÄ£¬ÏÓÂé·³¡£
¡¡¡¡ÍíÉÏ£¬Í» ......