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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL question

Status
Not open for further replies.

TGJ

Programmer
Jan 31, 2005
64
CA
Hi, I am trying to write a query to select some records from our database where the disabled date is greater than the date last paid by employer. In the database there are multiple similar records but the sequence number might be different, ie The sequence number might be 1, 2, 3, 4, etc. I want to choose the record with the largest sequence number. Here is my code, but it does not work.
Any help is much appreciated. Thanks.

SELECT * FROM DATA WHERE DISABLED_DATE > LAST_DAY_EMPL_PAID_DATE GROUP BY MAX(SEQUENCE_NUM)
 
how about this:

SELECT field1, Max(sequenceNum) FROM DATA WHERE
DISABLED_DATE > LAST_DAY_EMPL_PAID_DATE

-DNG
 
Tried that, get error: "not a single-group group function".

Any other suggestions??
 
How about:
[tt]
SELECT *
FROM data
WHERE disabled_date > last_day_empl_paid_date
ORDER BY sequence_num DESC
LIMIT 1
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top