Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Location
    NH
    Posts
    87

    Exclamation Unanswered: Invalid Column: Group By with SELECT calc column

    Hi all,

    Problem:
    Code:
    SELECT (FLOOR(( ACTIVITY_DATE - TO_DATE('05-01-04', 'MM-DD-YY') ) /7 )) As WEEKNO, SUM(some_data) FROM some_table WHERE TO_CHAR(ACTIVITY_DATE, 'MM-DD-YY') >= '05-01-2004' GROUP BY WEEKNO
    Returns an invalid column name. I'm trying to sum columns based upon which week they fall into. If I take out the SUM and GROUP BY it works; I don't understand why I can't GROUP BY WEEKNO, I have an aggregate function in my select statement?

    I've searched the web and can't find any answers and it's been about a day...

    Any help would be greatly appreciated!

    Thanks
    Warren

  2. #2
    Join Date
    May 2004
    Location
    NH
    Posts
    87
    Oh, one more thing...

    I have already tried moving the Week No calclution into the FROM clause in the form of it's own select statment and I still couldn't group by it after I referenced its alias... just in case someone was thinking of doing that.

  3. #3
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208
    Code:
    SELECT (FLOOR(( ACTIVITY_DATE - TO_DATE('05-01-04', 'MM-DD-YY') ) /7 )) 
    FROM ....
    WHERE .....
    GROUP BY (FLOOR(( ACTIVITY_DATE - TO_DATE('05-01-04', 'MM-DD-YY') ) /7 ))

Posting Permissions

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