select count sql server 2005

alfinete

Power Member
Código:
Select
    EnbEntidade.Nome                                                NameForm,
    EnbCorpo.Nome                                                    nameEntity,
    EnbCorpo.Codigo                                                    code,
    EnbEntidade.sexo                                                sex,
    year(EnbEntidade.DtNascimento)                                    YaarBirth,
    DATEDIFF (YY, EnbEntidade.DtNascimento, GETDATE()) -
    CASE WHEN (MONTH(EnbEntidade.DtNascimento)=MONTH(GETDATE())
    AND DAY(EnbEntidade.DtNascimento) > DAY(GETDATE())
    OR MONTH (EnbEntidade.DtNascimento) > MONTH (GETDATE()))
    THEN 1 ELSE 0 END AS                                            Age,
    Case When EnbNota.Aprovado = 1 
           Then 'Aprovado' 
           Else 'Não aprovado' End                                    Classification,
    EnbNota.Nota                                                    Note,
    EnbDCNota.E_Final                                                NoteF

  
From    EnbTurma

    Inner Join EnbDC On EnbDC.EnbDCId = EnbTurma.EnbDCId
    Inner Join EnbInscricao On EnbInscricao.EnbTurmaId = EnbTurma.EnbTurmaId
    Left Join EnbNota On EnbNota.EnbInscricaoId = EnbInscricao.EnbInscricaoId
    Left Join EnbDCNota On EnbDCNota.EnbDCNotaId = EnbNota.EnbDCNotaId
    Inner Join EnbEntidade On EnbEntidade.EnbEntidadeId = EnbInscricao.EnbEntidadeId
    Inner Join EnbCorpo On EnbEntidade.EnbCorpoId = EnbCorpo.EnbCorpoId
    Left Join EnbCategoria On EnbCategoria.EnbCategoriaId = EnbEntidade.EnbCategoriaId


Where        EnbTurma.EnbTurmaId =@EnbClasseId


gostava de neste select
fazer um count de sexo (m e f) e calcular a sua percentagem, e um count de aprovados e não aprovados e calcular a sua percentagem

agradecia uma ajuda
 
Back
Topo