troubleshooting Question

SQL Query pull values for list

Avatar of Dave KIlby
Dave KIlby asked on
SQL
3 Comments1 Solution9 ViewsLast Modified:
I want to pull data from a table, but I want to pull all the reasons and show 0 if there is no entry for the day.

This what I want the data to look like 
When I run this query, I only get Not Interested and Invalid Contact, is there a way to pull all the reasons and pull the number, 0 if null

SELECT Reason, Count(ID) from t_customers
where createddate = getDate()
group by Reason

I dont want to hardcode the reasons, as i want to include any new ones that might be added, so if I run this query it pulls all possible entries, and this list is what i want to utilize for the report.

select reason from t_customers
group by reason

Thanks

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros