Results 1 to 5 of 5
  1. #1
    vicki is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    5

    group and having

    the orginal query:



    SELECT DelMonth, DelDay, DelYear, Count(DelDate) AS countOfDelDate
    FROM mytbl
    WHERE item LIKE '70%-113%' OR item LIKE '73%-113%'
    GROUP BY DelMonth, DelDay, DelYear
    HAVING DelDay=21 AND DelMonth=02 AND DelYear=2014

    The original query i have above is actual select each fields from the table. I need to re-write this by select M, D, Y from the deliverydate but got an error. What did i have wrong here, can you plz help?
    thanks

    Modified:

    Select
    day(delDate) as del_d,
    month(delDate) as del_m,
    year(delDate) as del_y
    FROM mytbl
    WHERE item LIKE '70%-113%' OR item LIKE '73%-113%'
    group by del_d,del_m,del_y
    having del_d = 21
    and del_m =02
    and del_y = 2014
    Last edited by vicki; 02-21-2014 at 08:54 AM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't use # delimiters because these are not date values.

    Shouldn't you be using * wildcard?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    vicki is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    5
    no it's just the variables passed in from the form. I have it corrected, please let me know why i still got an error from the query.
    Error Executing Database Query. [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'day(delDate)' as part of an aggregate function.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Are you building this query in Access query builder? Or is this a VBA construct?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    It appears that
    day(delDate) as del_d
    has not been recognized as del_d in your Group By.

    Please tell us about your use of Access. I see java jdbc, odbc and Macromedia.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Report Group - Show empty Group
    By crimedog in forum Reports
    Replies: 2
    Last Post: 12-30-2013, 01:06 AM
  2. Replies: 0
    Last Post: 02-25-2013, 04:43 PM
  3. Replies: 2
    Last Post: 06-21-2012, 07:40 PM
  4. Group title carrying forward to next group
    By Amandasr12 in forum Reports
    Replies: 3
    Last Post: 06-06-2012, 02:13 PM
  5. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums