Commit f8874ca4 authored by dasharatha.vamshi's avatar dasharatha.vamshi

Update v_ba_stage_kpi.txt

parent 6fe1a519
SELECT bd.project_id, SELECT bd.project_id,
bd.master_product_id, bd.master_product_id,
bd.process_stage_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, CASE
((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, WHEN (floor((round((min(bd.batch_cycle_time))::numeric, 2) / (((365 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((round((min(bd.batch_cycle_time))::numeric, 2) / (((365 * 24) * 60))::numeric)))::text, 'y ')
((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, ELSE ''::text
((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, END ||
((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, CASE
((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 WHEN ((floor(((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)) > (0)::numeric) AND (floor(((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)) < (12)::numeric)) THEN concat((floor(((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)))::text, 'mon ')
ELSE ''::text
END) ||
CASE
WHEN ((floor((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)) > (0)::numeric) AND (floor((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)) < (4)::numeric)) THEN concat((floor((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)))::text, 'w ')
ELSE ''::text
END) ||
CASE
WHEN ((floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)) > (0)::numeric) AND (floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)) < (7)::numeric)) THEN concat((floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)))::text, 'h ')
ELSE ''::text
END) ||
CASE
WHEN ((floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)) > (0)::numeric) AND (floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)) < (60)::numeric)) THEN concat((floor((((((round((min(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)))::text, 'm')
ELSE ''::text
END) AS min_bct,
((((
CASE
WHEN (floor((round((avg(bd.batch_cycle_time))::numeric, 2) / (((365 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((round((avg(bd.batch_cycle_time))::numeric, 2) / (((365 * 24) * 60))::numeric)))::text, 'y ')
ELSE ''::text
END ||
CASE
WHEN (floor(((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor(((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)))::text, 'm ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)))::text, 'w ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)))::text, 'h ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round((avg(bd.batch_cycle_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)))::text, 'm')
ELSE ''::text
END) AS avg_bct,
((((
CASE
WHEN (floor((round((max(b.golde_batch_time))::numeric, 2) / (((365 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((round((max(b.golde_batch_time))::numeric, 2) / (((365 * 24) * 60))::numeric)))::text, 'y ')
ELSE ''::text
END ||
CASE
WHEN (floor(((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor(((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)))::text, 'm ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)))::text, 'w ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)))::text, 'h ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round((max(b.golde_batch_time))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)))::text, 'm')
ELSE ''::text
END) AS golden_bct,
((((
CASE
WHEN (floor((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) / (((365 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) / (((365 * 24) * 60))::numeric)))::text, 'y ')
ELSE ''::text
END ||
CASE
WHEN (floor(((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor(((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) / (((30 * 24) * 60))::numeric)))::text, 'mon ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)) > (0)::numeric) THEN concat((floor((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) / (((7 * 24) * 60))::numeric)))::text, 'w ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) / (60)::numeric)))::text, 'h ')
ELSE ''::text
END) ||
CASE
WHEN (floor((((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)) > (0)::numeric) THEN concat((floor((((((round(((max(t.ideal_batch_cycle_time) * (60)::double precision))::numeric, 2) % (((365 * 24) * 60))::numeric) % (((30 * 24) * 60))::numeric) % (((7 * 24) * 60))::numeric) % ((24 * 60))::numeric) % (60)::numeric)))::text, 'm')
ELSE ''::text
END) AS ideal_bct,
round((max(f.avg_quality))::numeric, 2) AS avg_quality,
round((max(f.ideal_quality))::numeric, 2) AS ideal_quality,
round((max(j.kpi_value))::numeric, 2) AS golden_batch_quality
FROM ((((batch_details bd FROM ((((batch_details bd
LEFT JOIN ( SELECT bd_1.batch_no, LEFT JOIN ( SELECT bd_1.batch_no,
bd_1.process_stage_id, bd_1.process_stage_id,
...@@ -37,5 +117,5 @@ ...@@ -37,5 +117,5 @@
bq.project_id bq.project_id
FROM batch_quality bq 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 (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)) WHERE ((bd.batch_start > (now() - '6 mons'::interval)) AND ((bd.batch_status)::text = 'completed'::text))
GROUP BY bd.project_id, bd.master_product_id, bd.process_stage_id; 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