Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 SQL Query

Author  Topic 

john_john
Starting Member

10 Posts

Posted - 2005-07-05 : 11:58:35
I am trying to create a custom SQL query that accepts a particular date as the input parameter and outputs all the occurences of the employer name column after that date until the present.

Here is a sample of the table that i have:

Table Name: Test
Date Name Type
06/21/2005 abc A
06/21/2005 xyz B
06/21/2005 fgh A
06/22/2005 asd A
06/22/2005 tyr B


The output should be as follows (for an input date of 06/20/2005 and Type being A):

Date Name
06/21/2005 abc
06/21/2005 fgh
06/22/2005 asd

Here is the query that I have so far and the error message that I get when I try to execute it:

SELECT Format([Date],"mm/dd/yyyy") AS [Request Date], test.[Employer-name]
FROM test
WHERE test.[Request-Type] = 'A'
GROUP BY Format([Request-Date],"mm/dd/yyyy")
HAVING (((DateDiff("d",[Please enter start date in mm/dd/yyyy format],(Format([Request-Date],"mm/dd/yyyy"))))>=0))
ORDER BY Format([Request-Date],"mm/dd/yyyy");

john_john
Starting Member

10 Posts

Posted - 2005-07-05 : 12:00:37
Here is the error message:

You tried to execute a query that does not inlcude the specified expression 'Employer-name' as part of an aggregate function.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-07-05 : 12:03:45
HAVING clauses are for aggregate SELECT statements only (i.e., with GROUP BY clauses). Read up on the basic structure of a SQL SELECT in either MS Access help or do some googling.

Your criteria should go in the WHERE clause.

- Jeff
Go to Top of Page
   

- Advertisement -