-
query help
I have a employee table with emp-name,emp-id and
date of joining
emp-name emp-id date of joining
john 1123 16/08/2001
tom 2345 02/02/2000
tim 4567 01/01/2001
jim 7890 03/04/2001
clarke 8797 09/09/1998
Now how can i get the year in which max employees joined from the given table?
The result should just be 2001 for the given table .
Please advice.
-
How about this:
SELECT distinct top 1 YEAR(JoinDate),count(*)
FROM YourTable group by year(JoinDate)
order by COUNT(*) desc
the tricky part might be what happens when two years have the same number of employees joined
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|