Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group data weekly

Status
Not open for further replies.

depistol

Programmer
Sep 16, 2005
2
CA
Hello,

I have a question. I want to pull data from 6 months back from all the employees and see who had more than 60 hours per week during the past 6 months.

So if an employee had more than 60 hours in only one week in the past 6 months, then I would need his name to show up in the query.

Is there a 'group/display per week' function in mySQL?

THanks
Depistol
 
Hi

Code:
[b]select[/b]
employee,min(work_day) [b]as[/b] week_start,max(work_day) [b]as[/b] week_end sum(worked_hour)

[b]from[/b] work_table

[b]where[/b] work_day>subdate(curdate(),6*30.5)

[b]group by[/b] employee,date_format(work_day,[i]"%U"[/i])

[b]having[/b] sum(worked_hour)>60;

Feherke.
 
Hi

Oops, missing comma ( , ).
Code:
[b]select[/b]
employee,min(work_day) [b]as[/b] week_start,max(work_day) [b]as[/b] week_end[red],[/red] sum(worked_hour)

[b]from[/b] work_table

[b]where[/b] work_day>subdate(curdate(),6*30.5)

[b]group by[/b] employee,date_format(work_day,[i]"%U"[/i])

[b]having[/b] sum(worked_hour)>60;

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top