Friday, 15 June 2012

sql server - Distinct counts per year -


Hello I am trying to redeem a person only once, even if a person has two nominations in the same year Select the different year, school, count (when [graduate] = 1 and [dropout] = 0 then IDED) as 'passed', in the case (in case when the [graduate] ] = 0 and [dropout] = 1 'dropped' in the form of 'idad', counting (in case when [graduate] = 0 and [dropout] = 0 then idide) as 'release' rhythm From the school where ID = '10' group year, my production is the year the school continued 2012 School 0 0 1 2013 School 0 0 1 2014 School 2 2 ID / 1 is issued for 2 students because the student is nominated twice. How can I get a specific count in this case?

You are wrong with DISTINCT , this is every COUNT Should be inside:

  SELECT [year], school, COUNT (in different cases when [graduation] = 1 and [dropout] = 0 again IDED), pass (wrong case When [graduate] = 0 and [dropout] = 1 then IDED dropped), COUNT ([graduation] = 0 and [dropout] = 0 IDED in different cases] then your table was released by WHERE ID = '10' group [Year], school;  

No comments:

Post a Comment