我是SQL Server的新手,遇到問題。將SQL列空值轉換爲0
我有這個視圖,其中公式中的某些列允許爲空。
如何將這些空值轉換爲0,因爲如果它們爲空,則公式的結果也將爲空。
謝謝!
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'](http://msdn.microsoft.com/zh-cn/library/ms184325.aspx)函數開始。 – vcsjones
使用'ISNULL'或'COALESCE()'函數。 –
這是爲什麼標記的.NET? – Paparazzi