Welcome Guest, Not a member yet? Register   Sign In
Workload calculation Problem
#2

[eluser]Bigil Michael[/eluser]
I have modified the table like this

and instead of subjects teachers id has been saved.

id Monday Tuesday wednesday thursday friday saturday

1 2 3 1 5 6
2 1 4 3 2 5


Now I want to take count of each days

written query like this

Code:
SELECT `S`.`stf_firstname` as teacher, count(T.monday) as monday_prd  FROM (`staffs` as S)
LEFT JOIN `timetable` as T ON `T`.`monday` = `S`.`stf_id`
GROUP BY `S`.`stf_id`
This code running fine and prints count of monday

Code:
SELECT `S`.`stf_firstname` as teacher, count(T.monday) as monday_prd,count(T1.tuesday) as tue_period  FROM (`staffs` as S)
LEFT JOIN `timetable` as T ON `T`.`monday` = `S`.`stf_id`
LEFT JOIN `timetable` as T1 ON `T1`.`tuesday` = `S`.`stf_id`
GROUP BY `S`.`stf_id`
It prints wrong count

can any one help to print multiple counts from same table with single left join



Messages In This Thread
Workload calculation Problem - by El Forum - 09-30-2014, 12:02 AM
Workload calculation Problem - by El Forum - 10-01-2014, 12:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB