Below is the easiest way to Calculate monthly leaves and late comings by an individual employee for the year 2010 at column level
Select emp_id , Date_format(e.registration_date,'%m-%y')
, (Select count(leave_id) from emp leave el
where e.emp_id=el.em_id
and Date_format(e.registration_date,'%m-%y')=Date_format(el.leave_date,'%m-%y')TotalLeaves
, (Select count(leave_id)
from emp_attendence ea
where e.emp_id=ea.emp_id
and Date_format(e.registration_date,'%m-%y')=Date_format(el.leave_date,'%m-%y')TotalLatecomings
from employee e
where e.registration_date between '2010-04-01 00:00:00' and '2010-12-31 23:59:59'
Labels
- AVG() Function (1)
- Aggregate Functions (1)
- Candidate Key (1)
- Composite and Compound Keys (1)
- EXISTS (1)
- FIRST() Function (1)
- Group By Statement (1)
- Having Clause (1)
- INSERT (1)
- LIKE (1)
- SELECT AS CLAUSE (1)
- SQL Distinct Unique Records (1)
- SQL IN (1)
- SQL Joins (1)
- SQL Last() Function (1)
- SQL NULL Conditional (1)
- SQL Not Exists (1)
- SQLComparison Operators (1)
- Sql Max() Function (1)
- Sql Min() Function (1)
- Sql SUM() Function (1)
- WHERE (1)
Blog Archive
-
▼
2010
(73)
-
▼
April
(21)
- Monthly Count at Column Level
- SQL SUM() Function
- SQL Min() Function
- SQL Max() Function
- SQL Last() Function
- SQL Not Exists
- FIRST() Function
- COUNT() function
- The AVG() Function
- SQL Aggregate Functions
- Group By Statement
- HAVING Clause
- SQL Joins
- Full Text Search
- CONTAINS Predicate
- WHERE Clause
- EXISTS
- Like Operator
- UNION/INTERSECT CLAUSES
- INSERT Statement Syntax
- SELECT - SQL Command
-
▼
April
(21)
Thursday, April 22, 2010
Monthly Count at Column Level
at
7:02 AM
Posted by
M.Junaid Khan
0
comments
Posted under :
Monthly Count at Column Level
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment