Hi again, here's what I'm doing:------------------------------------------------------------------------------IF OBJECT_ID('tempdb..#EmpTenure') IS NOT NULL DROP TABLE #EmpTenure------------------------------------------------------------------------------CREATE TABLE #EmpTenure( emp_id INT , months_tenure INT , term_date DATETIME , PRIMARY KEY (emp_id))INSERT INTO #EmpTenure SELECT 11111, 3, '1/1/2011'INSERT INTO #EmpTenure SELECT 22222, 3, '2/2/2011'INSERT INTO #EmpTenure SELECT 33333, 5, '3/3/2011'INSERT INTO #EmpTenure SELECT 44444, 6, '4/4/2011'INSERT INTO #EmpTenure SELECT 55555, 8, '5/5/2011'INSERT INTO #EmpTenure SELECT 66666, 8, '6/6/2011'INSERT INTO #EmpTenure SELECT 77777, 8, '7/7/2011'------------------------------------------------------------------------------SELECT e.months_tenure , [total_employees] = Count(*)FROM #EmpTenure eWHERE term_date <= getdate()GROUP BY e.months_tenureORDER BY e.months_tenure------------------------------------------------------------------------------
Of course, the real table has more fields and records, but this is just what I'm looking at right now.The result is:months_tenure total_employees--------------------------------- 3 2 5 1 6 1 8 3
And what I'd like is:months_tenure total_employees--------------------------------- 3 2 4 0 5 1 6 1 7 0 8 3
My question is: Is there a way to fill in those gaps in months_tenure (4 and 7, in the example) with a total_employees value of 0? The reason I ask is that I'm copying the results into Excel and making a graph, but the graph is a little misleading because there are never any zeroes displayed.Thanks, as always!