2013-08-25 70 views
0

我在做這個查詢:如何使查詢的字段在MySQL中是一個INT

select tblagenda.ValorServicio, ((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio/grupo.Total) as Copago, grupo.Total 
    from tblcopago 
    inner join tblagenda on (tblagenda.CodigoOrden=tblcopago.CodigoOrden) 
    join (select sum(ValorServicio) as Total, CodigoOrden from tblagenda group by CodigoOrden) grupo on grupo.CodigoOrden = tblagenda.CodigoOrden 

我想Copago場是一個INT

+1

只是猜測:ROUND()?地板() – Strawberry

回答

0

如果你想圓結果:

SELECT ROUND((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio/grupo.Total) as Copago 

如果你想地板它(截斷至下INT):

SELECT FLOOR((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio/grupo.Total) as Copago 

...如果你想上限值(截斷+ 1):

SELECT CEIL((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio/grupo.Total) as Copago 

MYSQL Mathematical Functions

相關問題