将SQL列空值转换为0 [英] Convert SQL column null values to 0
本文介绍了将SQL列空值转换为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是SQL Server的新手,但遇到了问题.
I'm new to SQL Server and I have an issue.
我有此视图,其中公式中的某些列允许为空.
I have this view, in which some of the columns from the formulas are allowed to be null.
如何将这些空值转换为0,因为如果它们为空,则公式的结果也将为空.
How could I convert these null values to 0 because if they are null, the result of the formula it will be also null.
谢谢!
CREATE VIEW vwAchizitii
AS
SELECT
ac_id
,[Company]
,No
,[ContractID]
,[Seller]
,[AcquistionDate]
,[Village]
,[Commune]
,[Area]
,[PlotArea]
,[FieldNo]
,[Topo1]
,[Topo2]
,[Topo3]
,[Topo4]
,[Topo5]
,[TotalAreaSqm]
,[OwnershipTitle]
,[CadastralNO]
,[Type]
,[Price]
,[NotaryCosts]
,[LandTax]
,[OtherTaxes]
,[AgentFee]
,[CadastralFee]
,[TabulationFee]
,[CertSarcini]
,[ProcuraNO]
,(price+notarycosts+landtax+othertaxes+agentfee+cadastralfee+tabulationfee+certsarcini) as TotalCosts
,(price+notarycosts+landtax+othertaxes+agentfee+cadastralfee+tabulationfee+certsarcini)/(TotalAreaSqm/10000) as RonPerHa
,(price+notarycosts+landtax+othertaxes+agentfee+cadastralfee+tabulationfee+certsarcini)/(TotalAreaSqm/10000*FixHist) as EurPerHa
,[DeclImpunere]
,[FixHist]
,(price+notarycosts+landtax+othertaxes+agentfee+cadastralfee+tabulationfee+certsarcini)/FixHist as EurHist
,[LandStatus]
FROM
nbAchizitii
推荐答案
您可以使用 ISNULL(Transact-SQL)
例如
(isnull(price,0)+isnull(notarycosts,0)) as Total
这篇关于将SQL列空值转换为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文