If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Attendance Report using MySql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-12, 10:14
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
Attendance Report using MySql

I want to write a query to generate attendance report of employee. First I will tell you how the presence of employee is stored in database.

I have following tables.

Code:
Employee Table with Columns

    emp_id  emp_Name  Joining_Date
     1        L         11-01-2012
     2        M         12-01-2012


Holiday Table

Holiday_Name         Date 
Chrismas          25-12-2012  
Dushera           08-03-2012
Independance Day  15-08-2012

Leave Table

Subject  from_Date     to_Date      Emp_Id     status 
PL       02-01-2012    04-01-2012      1       Approved
CL       11-01-2012    12-01-2012      2       Declined   


Doctor Table

Subject   Call_Date    call_Done_By(emp_id)
 Call     15-01-2012      1
 CA       21-02-2012      2

Chemist Table
Subject   Call_Date    call_Done_By(emp_id)
 Chemist   1-02-2012     2
 Texo      21-03-2012      1
If employee is visited to doctor or chemist,that particular date is stored in that particular doctor or chemist table with employee_id

Now I want output format like this way..................

Code:
Employee    Month    1  2   3   4   5   6    7.... 
 Name       Nov11    Y  Y   Y   Y   Y   L    S....
 Name 1     Dec11    Y  Y   Y   Y   Y   Y    S....
what will be the possible solutions for it?

Last edited by pravingate07; 02-06-12 at 05:05.
Reply With Quote
  #2 (permalink)  
Old 02-04-12, 11:27
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
Can you fix the underlying problems with the schema, or are you required to use bubble gum and bailing wire to make the existing schema work as best you can?

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 02-06-12, 00:46
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
Attendance Report using MySql

Yes I need to achieve this with existing schema.. as I have no control on schema.
Reply With Quote
  #4 (permalink)  
Old 02-07-12, 05:03
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
If anyone is getting any problem to understand my question, let me know.
I 'll try tel in another way.
Reply With Quote
  #5 (permalink)  
Old 02-07-12, 07:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by pravingate07 View Post
Now I want output format like this way..................
you will have to set up a CASE expression for each day of the month
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 02-07-12, 07:35
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
Attendance Report using MySql

yes I am also thinking in same way.. But you have any example that have used best case expression so far....
Reply With Quote
Reply

Tags
case

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On