Help with looping syntax

  • I'm trying to write a script that will give me a count of the towns where each students resides for each school. For example, School ABC has X students from Town XYZ. I was hoping someone could help me with the general syntax.

    Thanks.

  • Kenneth

    Some DDL would have been helpful.  Still, here's a guess.  Despite the title of the thread, you don't need a loop - you can do it with a set-based query.

    SELECT School, Town, COUNT(StudentID)

    FROM Students

    GROUP BY School, Town

    John

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply