Hello everyone as you can see in this case statement
my result set returns a row with 5 columns for the period of 4/4/2009 thru 4/11/2009
I need the next row to do the same for the period of 4/12/2009 thru 4/30/2009, not sure how to proceed, please help if you can thank you for reading this post.
SELECT Facility,Block,Cell_Number,
COUNT (CASE WHEN @@ROWCOUNT > 0 AND @@ROWCOUNT <=100 THEN 1 ELSE NULL END)AS [Days Housed]
,COUNT(CASE WHEN CellCount =1 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 1 ELSE NULL END) AS [Single Celled]
,COUNT(CASE WHEN CellCount =2 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 2 ELSE NULL END) AS [Double Celled]
,COUNT(CASE WHEN CellCount=3 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 3 ELSE NULL END) AS [Triple Celled]
,COUNT(CASE WHEN CellCount =4 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 4 ELSE NULL END) AS [Quad Celled]
,COUNT(CASE WHEN CellCount =5 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 5 ELSE NULL END) AS [Five Celled]
INTO #cells1
FROM #Cells
Group By Cell_Number,Block,Facility
my result set returns a row with 5 columns for the period of 4/4/2009 thru 4/11/2009
I need the next row to do the same for the period of 4/12/2009 thru 4/30/2009, not sure how to proceed, please help if you can thank you for reading this post.
SELECT Facility,Block,Cell_Number,
COUNT (CASE WHEN @@ROWCOUNT > 0 AND @@ROWCOUNT <=100 THEN 1 ELSE NULL END)AS [Days Housed]
,COUNT(CASE WHEN CellCount =1 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 1 ELSE NULL END) AS [Single Celled]
,COUNT(CASE WHEN CellCount =2 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 2 ELSE NULL END) AS [Double Celled]
,COUNT(CASE WHEN CellCount=3 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 3 ELSE NULL END) AS [Triple Celled]
,COUNT(CASE WHEN CellCount =4 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 4 ELSE NULL END) AS [Quad Celled]
,COUNT(CASE WHEN CellCount =5 AND DateHoused BETWEEN '4/4/2009' AND '4/11/2009' THEN 5 ELSE NULL END) AS [Five Celled]
INTO #cells1
FROM #Cells
Group By Cell_Number,Block,Facility