5
Contributors
4
Replies
26
Views
2 Years
Discussion Span
Last Post by kalxas
2

Antony, this is a serious question...

Do you think we can give you an answer to this without knowing your database schema?

2

Please take the time to articulate your question clearly and provide all the information that you have. Include DB schemas and any code that you've tried or are in the process of trying.

Asking this sort of ambiguous question presents contributors with problems. We are here to help, but we could be providing solutions that are not appropriate because you did not supply all the relevant details. This simply wastes our time and effort. You will not be thanked for it. We have discussed this before on other threads. Please take note of this.

The PHP forum has a great sticky:

https://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question

and although it deals with PHP, the majority of it is relevant to asking questions in general. Thank you.

Edited by diafol

0

Assume that you have a table to track every day yours employees records with working or absent, then try the following

where er.working = 1 the employee worked the er.recordDate and er.working = 0 the employee absent

SELECT 
    er.employeeId,
    SUM(CASE
        WHEN er.working = 1 THEN 1
        ELSE 0
    END) working,
    SUM(CASE
        WHEN er.working = 1 THEN 0
        ELSE 1
    END) absent
FROM
    employeeRecords AS er
WHERE
    er.recordDate BETWEEN '$from_date' AND '$to_date'
GROUP BY er.employeeId

George

Edited by kalxas: missing details

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.