View previous topic :: View next topic
|
Author |
Message |
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
Hi,
Let us consider the table Employee has the following columns,
Code: |
Emp_ID Join_DT
1 2010-10-12
2 2009-10-12
3 2010-10-12
4 2009-10-12
5 2010-10-12
6 2010-10-12
7 2010-10-12
8 2009-10-12
9 2010-10-12
10 2010-10-12
11 2009-10-12
12 2010-10-12 |
I Need to display the Year and the number of employees joined in that particular Year.
Can anyone please help me.. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Starter with: see if you can find a function (in the documentation - ur guess) that returns the year from a date column.
Then try just selecting these rows/cols.
Then if that looks good, try grouping.
Incrementally work your way to the solution. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Code: |
SELECT SUBSTR(CHAR(Join_DT),1,4),
COUNT(Emp_ID)
FROM Employee
GROUP BY SUBSTR(CHAR(Join_DT),1,4);
|
|
|
Back to top |
|
|
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
you can also use YEAR function to extract year part in the date column directly instead of SUBSTR.
SELECT CHAR(YEAR(Join-Dt)), COUNT(Emp_ID)
FROM Employee
GROUP BY CHAR(YEAR(Join_Dt))
WITH UR; |
|
Back to top |
|
|
|