Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Use the Min Function to Look for a Specific Date?

Status
Not open for further replies.

VAST39

Programmer
Sep 21, 2012
26
US
Hey guys,

I'm a bit stuck on a simple query. I can't remember how to use the min function to compare against a specific date. For my query, I want to find employees where their first service date occurs after july 1, 2005. I wrote this query, but I get a syntax error:

Code:
SELECT  SSSN from history
where min(B.SERVICEDT) > '2005-07-01'


What am I missing here?
 
Code:
SELECT SSSN
from history
HAVING min(history.SERVICEDT) > '20050701'
?

Borislav Borissov
VFP9 SP2, SQL Server
 
Sorry, you should add GROUP BY:
Code:
SELECT SSSN
from history
GROUP BY SSSN
HAVING min(history.SERVICEDT) > '20050701'

Borislav Borissov
VFP9 SP2, SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top