Commit 304ed3a0 authored by dasharatha.vamshi's avatar dasharatha.vamshi

Upload New File

parent f6aab660
SELECT bd.project_id,
bd.master_product_id,
bd.process_stage_id,
((replace(to_char(round((min(bd.batch_cycle_time) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((min(bd.batch_cycle_time))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS min_bct,
((replace(to_char(round((avg(bd.batch_cycle_time) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((avg(bd.batch_cycle_time))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS avg_bct,
((replace(to_char(round((max(b.golde_batch_time) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((max(b.golde_batch_time))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS golden_bct,
((replace(to_char(round((max(t.ideal_batch_cycle_time) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((max(t.ideal_batch_cycle_time))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS ideal_bct,
((replace(to_char(round((max(f.avg_quality) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((max(f.avg_quality))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS avg_quality,
((replace(to_char(round((max(f.ideal_quality) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((max(f.ideal_quality))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS ideal_quality,
((replace(to_char(round((max(j.kpi_value) / (60)::double precision)), 'FM99999'::text), ' '::text, '0'::text) || ':'::text) || replace(to_char(round((((max(j.kpi_value))::integer % 60))::double precision), 'FM99'::text), ' '::text, '0'::text)) AS golden_bacth_quality
FROM ((((batch_details bd
LEFT JOIN ( SELECT bd_1.batch_no,
bd_1.process_stage_id,
bd_1.master_product_id,
bd_1.batch_cycle_time AS golde_batch_time,
bd_1.project_id
FROM batch_details bd_1
WHERE (bd_1.golden_batch IS TRUE)) b ON ((((b.project_id)::text = (bd.project_id)::text) AND ((b.process_stage_id)::text = (bd.process_stage_id)::text) AND ((b.master_product_id)::text = (bd.master_product_id)::text))))
LEFT JOIN ( SELECT DISTINCT bd_1.process_stage_id,
bd_1.master_product_id,
bd_1.ideal_batch_cycle_time,
bd_1.project_id
FROM batch_details bd_1
WHERE (bd_1.ideal_batch_cycle_time IS NOT NULL)) t ON ((((t.project_id)::text = (bd.project_id)::text) AND ((t.process_stage_id)::text = (bd.process_stage_id)::text) AND ((t.master_product_id)::text = (bd.master_product_id)::text))))
LEFT JOIN ( SELECT bq2.process_stage_id,
bq2.kpi_name,
avg(bq2.kpi_value) AS avg_quality,
avg(bq2.kpi_value) AS ideal_quality,
bq2.project_id
FROM batch_quality bq2
WHERE (bq2.critical_parameter IS TRUE)
GROUP BY bq2.process_stage_id, bq2.kpi_name, bq2.project_id) f ON ((((f.project_id)::text = (bd.project_id)::text) AND ((f.process_stage_id)::text = (bd.process_stage_id)::text))))
LEFT JOIN ( SELECT bq.batch_no,
bq.process_stage_id,
bq.kpi_name,
bq.kpi_value,
bq.project_id
FROM batch_quality bq
WHERE (bq.critical_parameter IS TRUE)) j ON ((((j.project_id)::text = (b.project_id)::text) AND ((j.batch_no)::text = (b.batch_no)::text) AND ((j.process_stage_id)::text = (b.process_stage_id)::text))))
WHERE (bd.batch_start > (now() - '6 mons'::interval))
GROUP BY bd.project_id, bd.master_product_id, bd.process_stage_id;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment