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

Query problem

Status
Not open for further replies.

akinia

Programmer
Nov 23, 2000
69
0
0
BE
Hi every one,

I've a little problem to acheive this query.
There is table with the following fields:
Empl_No
Date(Numeric)
Group_Nr

Now the datas:
001 001 001 001
5400 5440 5470 5485
A B C A

I need to retrieve the group at a distinct date; for example
I need the last group for the date before 5475. The result is C.

Any help will be appreciated.

Thanks in advance ;-)
 
Hi,

After a good reflexion and many tests, I've finally found the solution.
Here is the SQL :

SELECT EMPL_NO, MAX(Date) as MaxDate,
(SELECT Group_Nr FROM <Table_Name> TN WHERE
TN.Date = Max(S.Date) as Grp
FROM <Table_Name> S WHERE Date <= <Date> GROUP BY
EMPL_NO

Sorry for this thread ; I hope it could help somebody.

;-))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top