My query returns null if the columns are empty. It should return 0 so I can compute it inside my codes.
I've search through the web and found the "COALESCE" and "ISNULL" I am using SQL Server 2012 what should I use? and I tried the ISNULL and its not working in my query. This is my code.
SqlCommand cmd2 = new SqlCommand("SELECT ISNULL(SUM (Male) as Male, SUM(Female) as Female ,SUM(Pax) as Pax,SUM(Single) as Single,SUM(Married) as Married,SUM(Students) as Students,SUM(Elementary) as Elementary,SUM(Highschool) as Highschool,SUM(College) as College,SUM(PWD) as PWD, SUM([AR Users]) as ARUsers,SUM([12 Below]) as age1,SUM([13-21]) as age2,SUM([22-35]) as age3,SUM([36-50]) as age4,SUM([51-65]) as age5,SUM([65 Above]) as age6 ,0) FROM [tbl_ForeignVisit] where [Date Added] >= '"
+ dateTimePicker1.Value.Date.ToShortDateString() + "' AND [Date Added] <='" + dateTimePicker2.Value.Date.ToShortDateString() + "' ;", connection);