PRB: ????? ????? ?? ???? ??? ??????? SUM ?? AVG ????? ?? ???? ?? ?????

?????? ????????? ?????? ?????????
???? ???????: 281341 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

???????

??? ??????? ???? SUM ?? AVG ??????? ?? ?????? ???? ??????? ?????. ???? ????? ????? ??? ????? ?? ?? ??? ??? ?????? ??? ?????? ????? ?? ????.

?????

???? ??? ?????? ???? ???? ????? ????? ???????? ??????? ???????? ? ?????? ???? ?????? ????? ???? ?????. ???????? ??? "??? SQL Server ???????" ? ????? sum(numeric(p,s)) ?? numeric(38,s). ?? ???? ?????? ??????? ?? sum(amount) numeric(38,9). ???? ????? numeric(38,9) / numeric(15,9); ????????? ???? ?????? numeric(63,25). ??? ???? ??? ????? ?????? 38 ??????? ??????? ??? (38,6).

???? ??????

??????? ?????? ??? ??? ???????? ?????? ?? ?? ??? ????????:
  • ?????? ????? ??????? ????. ??? ???? ??????:

    DECLARE @Quantity numeric(15,9)
    SET @Quantity = 3
    
    SELECT Round(CAST(Sum(t1.Amount) AS numeric(15,9))/@Quantity, 9) As Cost
    FROM t1
    
    					
  • ????? ??????? ?? ????? ????? ?? ?????? ??????? ?? ??????. ??? ???? ??????:

    
    declare @quantity numeric (15,9)
    set @quantity = 3
    
    declare @sum numeric (15,9)
    set @sum= (select sum(amount) from t1)
    select @sum/@quantity as cost
    
    					
  • ??? ???? ????? ?? ????. ??? ???? ??????:
    select sum(Amount)/3 from t1
    					

??????? ????

?????? ?????? ????? ????????? ?????? ?? "??????? ????":
CREATE TABLE t1 
(
    Amount    numeric(15,9)    
)
GO
INSERT INTO t1( Amount ) VALUES (0.7)
INSERT INTO t1( Amount ) VALUES (1.3)
SELECT Amount FROM t1

/* result (correct, scale = 9)
Amount    
  
----------------- 
.700000000
1.300000000

DECLARE @Quantity numeric(15,9)
SET @Quantity = 3
    
SELECT t1.Amount / @Quantity As Cost
FROM t1
				
Again ? ????? ?????? ??? ?? ??????.

??? ???? ??? ??????? ??? ???????? ????????

DECLARE @Quantity numeric(15,9)<BR/>
SET @Quantity = 3

SELECT Sum(t1.Amount)/@Quantity As Cost<BR/>
FROM t1
				
.666666 ???? ???????.

?? ???? ????? ????? ??? ??? ?????? ???? ????? ????? ?????? ???????? ?? ????. ?? ???? ????? ????? ??? ??? ???? ?? ???? ???????:

select sum(Amount)/3 from t1
GO
select 2.0000000/@quantity

				
???? ????? ?? ?? ????? ??? ?????? SUM(amount) ?? ????? ?? ?????? ???????. ???? ????? ????? ??? ??? ??????? ?????? ????????? SUM ?? AVG ?? ???? ?????? ?? ??????.
declare @quantity numeric (15,9)
set @quantity = 3

declare @sum numeric (15,9)
set @sum= (select sum(amount) from t1)

select @sum/@quantity as cost
				

???????

???? ???????: 281341 - ????? ??? ??????: 20/?????/1424 - ??????: 3.2
????? ???
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition
????? ??????: 
kbmt kbprb KB281341 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????281341

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com