Results 1 to 3 of 3

Thread: Grouping Query

  1. #1
    Join Date
    Mar 2003

    Unanswered: Grouping Query

    I asked a question about this earlier, but im still having problems

    I found this code:

    SELECT Age, IIf([Age]>19,"Adult","Child") AS Category
    FROM QueryName;

    it works fine for grouping into 2 categories, Child and Adult, but I want to group into 8 groups
    PeeWee-11 and under

    Bantam-12 and 13
    Midget-14 and 15
    and continuing up to "Senior-Over 35"

    can someone please help, and tell me if i can use that code, or show me proper code(i dont know advanced coding)


  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you didn't like the idea of a group table?

    fine, you can nest the IIF function

    me, i think it gets messy about three levels deep, not to mention how very unpleasant it is to make changes if the age groups need to change, plus, you need to do this in any query that needs categories

    SELECT Age
    , IIf(Age < 12,'PeeWee'
    , IIf(Age in (12,13),'Bantam'
    , IIf(Age in (14,15),'Midget'
    , IIf(Age in (16,17),'xxxxxxx'
    , IIf(Age in (18,19),'xxxxxx'
    , IIf(Age in (20,21),'xxxxxxx'
    , IIf(Age < 35,'xxxxx'
    , 'Senior'))))))) as Category
    FROM QueryName;


  3. #3
    Join Date
    Mar 2003
    thank you so much!! it works just like i need it now.

    there shouldn't be a problem with the age classes changing or anything.
    Last edited by SugeTek; 04-03-03 at 01:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts