• You should read about aggregate functions. There are many places to read, but you can get a quick start by using the Stairway to T-SQL DML on this site[/url].

    Your query would look something like this:

    SELECT gender,

    COUNT(DISTINCT student) total, --Use student as different students can share the name but not student id

    year

    FROM YourTable

    GROUP BY gender, year

    Try to read something about data normalization[/url] which might complicate things on the beginning, but you'll be grateful when things start to get serious.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2