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 > MySql Query Count_Working_Days

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-12, 06:11
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
Exclamation MySql Query Count_Studied_Days

I have Emp table with following values

Code:
Emp_Id  Emp_Name    Subject        Dates
001      Smith      Java         07-02-2012
001      Smith      oracle       08-02-2012
001      smith      C++          10-02-2012
002      john       java         01-01-2012
002      john       SE           10-01-2012
002      john       c            10-01-2012  
001      smith      physics      04-01-2012
001      smith      c#           07-02-2012
001      smith     javascript    07-02-2012
Now as we can see here smith studied only 3 days for month February and 1 for month Jan while john studied only 2 days for month January.

How can we calculate this count for any employee? As a e.g:Output should be in following way.
Code:
Emp_Id   Emp_Name  Month_Year   No_Of_Days_Studied_In_Month
001      smith      Feb12                 3
001      smith      Jan12                 1
002      john       Jan12                 2

Last edited by pravingate07; 02-07-12 at 06:39.
Reply With Quote
  #2 (permalink)  
Old 02-07-12, 07:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
you want COUNT(DISTINCT emp.date), not COUNT(emp.date)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-08-12, 01:30
pravingate07 pravingate07 is offline
Registered User
 
Join Date: Feb 2012
Location: Pune,INDIA
Posts: 6
MySql Query Count_Studied_Days

yes, its working....
Reply With Quote
Reply

Tags
count, date, mysql

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