欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

SQLServer数据库Isnull()CAST()函数实例讲解

程序员文章站 2022-08-11 10:54:21
SELECT isnull(Sum(CAST(DAY0 AS DECIMAL(8,2)) ),0) as DAYSALES from SMASTOREFORECASTINFO I...

SELECT isnull(Sum(CAST(DAY0 AS DECIMAL(8,2)) ),0) as DAYSALES from SMASTOREFORECASTINFO

Isnull(): Sum(CAST(DAY0 AS DECIMAL(8,2)) )为NULL 时候 会把0赋值给DAYSALES

CAST():CAST(DAY0 AS DECIMAL(8,2)) 将每天的DAY0 值最多8位储存,2位小数