简体   繁体   中英

Sum column values and also check null condition

我将此列转换为金钱,并且最重要的是,我需要对该列值求和,并且需要设置验证,例如该列是否具有空值,它必须返回零。

select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, Amt_Value)),1) as  [Amount]  from Products

使用SUM和ISNULL

select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, ISNULL(SUM(Amt_Value),0.00))),1) as  [Amount]  from Products

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM