#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    2
    Rep Power
    0

    GROUP BY question


    I have a relation called Orders with the following attributes:
    OrderId, total_price, date, customerId.
    Where OrderId is the primary key and customerId a foreign key referencing another relation. Does anybody know how can I group the tuples of this relation acording to year and month only? If a say for example something like "GROUP BY date" my data will be grouped by year, month and day. I am only looking for the first two.
    Thanks in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,376
    Rep Power
    391
    Code:
    select y,m,count(*)
    from (select extract(year from date) as y,
    extract(month from date) 
     from orders) as dt
    group by y,m
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    2
    Rep Power
    0
    Thanks I'll give it a try

IMN logo majestic logo threadwatch logo seochat tools logo