Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
balakrishna
Starting Member
1 Post |
Posted - 2008-06-21 : 02:42:21
|
Hello! suppose i have two tables, table1 columns(empcode (pk), empDept) and table2 columns(empcode (FK),Date,Attendance) i wanted to write a query to get output like DEPT ABSENT----------------------------- Accounts 10 EDP Section 0 ** Admin 2 Stationary 0**if no employee is absent in the department it has to display Zero |
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2008-06-21 : 04:26:59
|
try thisSELECT T1.empDept, COUNT(T2.Attendance)FROM table1 T1LEFT JOIN table2 T2 ON T1.empcode = T2.empcodeGROUP BY T1.empDept |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-21 : 05:06:26
|
quote: Originally posted by balakrishna Hello! suppose i have two tables, table1 columns(empcode (pk), empDept) and table2 columns(empcode (FK),Date,Attendance) i wanted to write a query to get output like DEPT ABSENT----------------------------- Accounts 10 EDP Section 0 ** Admin 2 Stationary 0**if no employee is absent in the department it has to display Zero
Is attendance a bit field? |
|
|
|
|
|