Count for groups and sub-groups?

This works because the silent ELSE in the CASE gives NULL, and COUNT will ignore this.

SELECT MONTH(Date) Month, YEAR(Date) Year, COUNT(*) Total, COUNT(CASE WHEN Status IN ('Gone', 'Cancelled') THEN 1 END) Lost, COUNT(CASE WHEN Status= 'Won' THEN 1 END) Won FROM MyTable GROUP BY MONTH(Date), YEAR(Date) This works because the silent ELSE in the CASE gives NULL, and COUNT will ignore this.

Answer editted because you miss the column names and the "Lost" Status restriction. – aF. Dec 6 at 13:28 What about the "gone" restriction as well then?

Oddly the sample data doesn't show a "lost" status – xQbert Dec 6 at 13:29 @aF: thanks, mixed up gone and lost – gbn Dec 6 at 13:32 @xQbert: I mixed up gone and lost... – gbn Dec 6 at 13:32 I am impressed. 3 minutes after question I got good answer. Thank you very much.

– sunprophit Dec 6 at 13:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions