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.
How could I convert these null values to 0 because if they are null, the result of the formula it will be also null.
Thanks!
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
Well, someone should put in a word for ANSI standards:
coalesce(<column>, 0)
isNULL
is specific to databases (and even does different things in some databases).
You can use ISNULL (Transact-SQL)
eg
(isnull(price,0)+isnull(notarycosts,0)) as Total
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With