views:

19

answers:

1

I have two tables, one parts_raised and another is parts_detail. parts_raised:

SN(int),Job_Number(int),Category(varchar),Part_code(int),technician(varchar),Time      (timestamp),

Parts_detail:

Part_code(int),Value(int),Descriptions(text),

part_code is same in both table.

How can i write query for achieving total count of jobs,and their total cost per technician on daily basis.

technician    day1                             day2            
              Total Jobs     total cost        Total Jobs     total cost   

Technician-1  4                 153              5              253
Technician-2  7                 352              2              256

How can achieve this or suggest any other method for getting same result.

Thanks in Advanced

A: 

Does this do it?

SELECT
  technician, Job_day, SUM(Value)
FROM
(
  SELECT
    pr.technician, DAY(pr.Time) AS Job_day, pd.Value 
  FROM
    parts_raised AS pr
  JOIN
    Parts_detail AS pd
  ON
    pd.Part_code = pr.Part_code
) AS tempId
GROUP BY
  technician, Job_day
Thomas
@Thomas thank you very much.