2012-02-29 110 views
0

我有以下的Sql查詢,其中我使用圓功能,但它不刪除點後的小數點。SQL Server刪除點後

這裏查詢

SELECT  animal_code, ROUND(SUM(calve_milk + evening + morning)/31, 0) AS Expr1 
FROM   Status 
WHERE  (animal_code = 147) AND (m_date BETWEEN '1/1/2012' AND '1/31/2012') 
GROUP BY animal_code 

此查詢結果

10.00000 

而且我想我能做到這一點在SQL Server 2005

回答

2

添加從此query.How只得到10 CAST圍繞着你的ROUND

CAST(ROUND(SUM(calve_milk + evening + morning)/31, 0) AS INT)

0

使用此SQL查詢:

SELECT  animal_code, CAST(ROUND(SUM(calve_milk + evening + morning)/31, 0) as BIGINT) AS Expr1 
0

轉換舍入結果爲整數。

例如:

SELECT CONVERT(Int, ROUND(1234.1234, 0))