Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Dec 2001
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Group By Month Year (2003)

    Dear Colleagues,

    I am unable to group the following query on Month and Year. Instead I get group on Date. I need result as: MMYY Count.

    t_d1 is table name. Date spans years 2003 to 2005.

    SELECT t_d1.TYP, Count(*) AS CNT, Format((t_d1.DATE),"yy/mm") AS MMYY
    FROM t_d1
    GROUP BY t_d1.TYP, t_d1.DATE
    ORDER BY 1, t_d1.DATE;

    Tried Group by Month(t_d1.DATE), Year(t_d1.DATE), No Joy.

    Please help.

    Selva.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Group By Month Year (2003)

    Try

    SELECT t_d1.TYP, Count(*) AS CNT, Format(t_d1.DATE,"yy/mm") AS MMYY
    FROM t_d1
    GROUP BY t_d1.TYP, Format(t_d1.DATE,"yy/mm")

    or

    SELECT t_d1.TYP, Count(*) AS CNT, Year(t_d1.DATE) AS Y, Month(t_d1.DATE) AS M
    FROM t_d1
    GROUP BY t_d1.TYP, Year(t_d1.DATE), Month(t_d1.DATE)

  3. #3
    Lounger
    Join Date
    Dec 2001
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Group By Month Year (2003)

    Dear Hans,

    As always, to the rescue! Works just great. Thanks a million!

    Selva

Posting Permissions

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