Connecting Tech Pros Worldwide Help | Site Map

Query error - "expression not part of aggregate function"

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 06:05 AM
deko
Guest
 
Posts: n/a
Default Query error - "expression not part of aggregate function"

SELECT Nz(Min([ApptDate]),#1/1/1000#) AS NextAppt, Appt_ID
FROM tblAppointments
WHERE Entity_ID=[Forms]![frm0]![Entity_ID] AND ApptDate>=Date()

If I do not include Appt_ID, it works fine. But I need the ID so I can join
other queries to this one. My guess is this is an elementary error...

Thanks in advance.



  #2  
Old November 13th, 2005, 06:05 AM
Douglas J. Steele
Guest
 
Posts: n/a
Default Re: Query error - "expression not part of aggregate function"

Anytime you use an aggregate function such as Min, Max, Avg, Count, etc, you
need to use a GROUP BY expression for all of the other fields not in an
aggregate function:

SELECT Nz(Min([ApptDate]),#1/1/1000#) AS NextAppt, Appt_ID
FROM tblAppointments
WHERE Entity_ID=[Forms]![frm0]![Entity_ID] AND ApptDate>=Date()
GROUP BY Appt_ID


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"deko" <www.clearpointsystems.com@use_contact_form.com> wrote in message
news:SCXDd.480$JI3.63@newssvr14.news.prodigy.com.. .[color=blue]
> SELECT Nz(Min([ApptDate]),#1/1/1000#) AS NextAppt, Appt_ID
> FROM tblAppointments
> WHERE Entity_ID=[Forms]![frm0]![Entity_ID] AND ApptDate>=Date()
>
> If I do not include Appt_ID, it works fine. But I need the ID so I can
> join
> other queries to this one. My guess is this is an elementary error...
>
> Thanks in advance.
>
>[/color]


  #3  
Old November 13th, 2005, 06:05 AM
deko
Guest
 
Posts: n/a
Default Re: Query error - "expression not part of aggregate function"

> SELECT Nz(Min([ApptDate]),#1/1/1000#) AS NextAppt, Appt_ID[color=blue]
> FROM tblAppointments
> WHERE Entity_ID=[Forms]![frm0]![Entity_ID] AND ApptDate>=Date()
> GROUP BY Appt_ID[/color]

Ah! I had tried GROUP BY AppDate...

Thanks for the help!


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.