[prog] mysql query
alwanza at oz.net
Sun Apr 2 12:47:40 EST 2006
Hello Wolf Rising,
How does the Database handle employees with no absences? Is there a NULL
field somewhere or do they just NOT populate one of the tables?
However you write the query, to get the output you want, your query needs to
match how the information is stored in the database.
Maybe problem is that when an employee has NO absenses there is no record
for that employee in whatever "s_code" you are using to obtain the "count"
You can't find employees with perfect attendence if you included that
attendance.status = 'absent'
in your query UNLESS the ASSOCIATED field has been designed to hold NULLs or
zeros when there are none (then you can search for NULL in that field by
adding an "OR").
Another way to tackle the same problem: Can you write a query that will
display ONLY employees with perfect attendance in the results?
I hope this helps, if not, maybe you can provide more info about how the
database is designed.
Date: Wed, 29 Mar 2006 23:51:53 -0500
From: "Wolf Rising" <wolfrising at gmail.com>
Subject: [prog] mysql query
To: programming at linuxchix.org
<72372a090603292051w7a83f9e1x9d3bfe69e8e65256 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
I am trying to run a query which returns how many employees missed less than
3 shifts during the winter season. The query works except it doesn't show
who had perfect attendance. Is there anyway to modify the current
query to include
those individuals who missed zero shifts? An employee's status for the day
may be recorded as absent, late or present.
Thanks for any assistance :-)
as total from
attendance.s_code = employee.s_code and
attendance.s_code = season.s_code and
employee.s_code = season.s_code and
attendance.season = season.season and
attendance.year= season.year and
attendance.status = 'absent' and
s_code having count(*) < 4 order by total asc, l_name;
More information about the Programming