sql
This commit is contained in:
@@ -83,14 +83,14 @@ end if;
|
||||
|
||||
/* trimming data */
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Objective' where lower(column10) like 'objective%';
|
||||
set column11='Objective' where lower(column11) like 'objective%';
|
||||
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Acceptance criteria' where lower(column10) like 'acceptance criteria%';
|
||||
|
||||
|
||||
update staging2.stg_specific_table_IHTBT30_BT30
|
||||
set column10='Condition' where lower(column10) like 'condition%';
|
||||
set column11='Condition' where lower(column11) like 'condition%';
|
||||
|
||||
update transactional.source_config set F1_source=F1_modified ;
|
||||
|
||||
@@ -205,39 +205,39 @@ perform fw_core.fn_jobctl_block_begin(__client_id,__function_id,__file_syspk,
|
||||
err_block:='IHTBT30_BT30_H1_BLOCK';
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select a.column3,column5 from staging2.stg_process_table_IHTBT30_BT30 a where block_tag='IHTBT30_BT30_H1'
|
||||
and block_row_number <=9;
|
||||
and block_row_number <=11;
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select a.column7,column9 from staging2.stg_process_table_IHTBT30_BT30 a where block_tag='IHTBT30_BT30_H1'
|
||||
and block_row_number <=9;
|
||||
and block_row_number <=10;
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Objective',column10
|
||||
select 'Objective',column11
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where column10='Objective'
|
||||
where column11 like 'Objective%'
|
||||
and block_tag='IHTBT30_BT30_H1'
|
||||
);
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Acceptance criteria',column8
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1' and block_row_number=11;
|
||||
where block_tag='IHTBT30_BT30_H1' and block_row_number=13;
|
||||
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Condition',column10
|
||||
select 'Condition',column11
|
||||
from staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where block_tag='IHTBT30_BT30_H1'
|
||||
and row_number=
|
||||
(
|
||||
select row_number+1 from
|
||||
staging2.stg_process_table_IHTBT30_BT30 a
|
||||
where column10='Condition'
|
||||
where column11 like 'Condition%'
|
||||
and block_tag='IHTBT30_BT30_H1'
|
||||
);
|
||||
|
||||
@@ -246,19 +246,19 @@ and block_tag='IHTBT30_BT30_H1'
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test std',column4
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=11
|
||||
where block_row_number=13
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test std Id',column3
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=11
|
||||
where block_row_number=13
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
insert into staging2.IHTBT30_BT30_H1_INT (c1,c2)
|
||||
select 'Test Standard ref',split_part(column3,':',2)
|
||||
from staging2.stg_process_table_IHTBT30_BT30 b
|
||||
where block_row_number=10
|
||||
where block_row_number=12
|
||||
and block_tag='IHTBT30_BT30_H1';
|
||||
|
||||
|
||||
@@ -290,6 +290,8 @@ Test_Request_no,
|
||||
Sample_Receipt_Date,
|
||||
Test_report_No,
|
||||
Tractor_Model,
|
||||
tractor_power_hp,
|
||||
variant,
|
||||
Generation,
|
||||
Customer_Name,
|
||||
Test_Engineer,
|
||||
@@ -299,19 +301,20 @@ No_of_Sample,
|
||||
Test_Start_Date,
|
||||
Test_End_Date,
|
||||
Tractor_Sr_No,
|
||||
drive,
|
||||
platform,
|
||||
Test_Standard_Refer,
|
||||
Domestic_Export,
|
||||
Operator_Name,
|
||||
Project_Group,
|
||||
Platform,
|
||||
Objective,
|
||||
Acceptance_Criteria,
|
||||
condition,
|
||||
Test_Standard,
|
||||
Test_Standard_id,
|
||||
Test_Standard_ref,
|
||||
Remarks,
|
||||
Observations
|
||||
Observations,
|
||||
Remarks
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
@@ -319,33 +322,11 @@ FROM crosstab(
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[c2::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_H1_INT
|
||||
ORDER BY generate_series(1,15),2'
|
||||
ORDER BY generate_series(1,15),syspk,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text,a_7 text,a_8 text,
|
||||
a_9 text,a_10 text,a_11 text,a_12 text,a_13 text,a_14 text,a_15 text,a_16 text,a_17 text,
|
||||
a_18 text,a_19 text,a_20 text,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text);
|
||||
a_18 text,a_19 text,a_20 text,a_21 text,a_22 text,a_23 text,a_24 text,a_25 text,a_26 text,a_27 text,a_28 text,a_29 text);
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Sample_Receipt_Date=case
|
||||
when Sample_Receipt_Date like '%-%' then Sample_Receipt_Date::timestamptz
|
||||
else date '1899-12-30' + Sample_Receipt_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_Report_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_Start_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
update staging2.IHTBT30_BT30_H1_Block
|
||||
set Test_End_Date=case
|
||||
when Test_Report_Date like '%-%' then Test_Report_Date::timestamptz
|
||||
else date '1899-12-30' + Test_Report_Date::int * interval '1' day
|
||||
end;
|
||||
|
||||
delete from staging2.IHTBT30_BT30_H1_Block where dummy_f is null ;
|
||||
update staging2.IHTBT30_BT30_H1_Block set model=__model;
|
||||
@@ -432,15 +413,14 @@ ply_rating
|
||||
)
|
||||
SELECT *
|
||||
FROM crosstab(
|
||||
'SELECT unnest(''{column10,column11}''::text[]) AS col
|
||||
'SELECT unnest(''{column11,column12}''::text[]) AS col
|
||||
, row_number() OVER ()
|
||||
, unnest(ARRAY[column10::text,column11::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_Weight_Tyre_Int where column11 is not null or column10 is not null
|
||||
, unnest(ARRAY[column11::text,column12::text]) AS val
|
||||
FROM staging2.IHTBT30_BT30_Weight_Tyre_Int where column11 is not null or column12 is not null
|
||||
ORDER BY generate_series(1,15),block_row_number,2'
|
||||
) t (col text,a_1 text,a_2 text,a_3 text,a_4 text,a_5 text,a_6 text);
|
||||
|
||||
|
||||
|
||||
delete from staging2.IHTBT30_BT30_Tyre_Details_Block where dummy_f is null ;
|
||||
update staging2.IHTBT30_BT30_Tyre_Details_Block set model=__model;
|
||||
execute 'update staging2.IHTBT30_BT30_Tyre_Details_Block set
|
||||
@@ -489,13 +469,13 @@ ORDER BY block_row_number ASC
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_1_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
set column11= b.first_value from (SELECT
|
||||
block_row_number,column11, value_partition, first_value(column11) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_1_Block
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
@@ -553,14 +533,15 @@ ORDER BY block_row_number ASC
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_2_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
set column11= b.first_value from (SELECT
|
||||
block_row_number,column11, value_partition, first_value(column11) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_2_Block
|
||||
where block_row_number > 2
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
@@ -617,14 +598,15 @@ ORDER BY block_row_number ASC
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_3_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
set column11= b.first_value from (SELECT
|
||||
block_row_number,column11, value_partition, first_value(column11) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_3_Block
|
||||
where block_row_number > 2
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
@@ -681,14 +663,15 @@ ORDER BY block_row_number ASC
|
||||
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Res_4_Block a
|
||||
set column10= b.first_value from (SELECT
|
||||
block_row_number,column10, value_partition, first_value(column10) over (partition by value_partition order by block_row_number)
|
||||
set column11= b.first_value from (SELECT
|
||||
block_row_number,column11, value_partition, first_value(column11) over (partition by value_partition order by block_row_number)
|
||||
FROM (
|
||||
SELECT
|
||||
block_row_number,
|
||||
column10,
|
||||
sum(case when column10 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
column11,
|
||||
sum(case when column11 is null then 0 else 1 end) over (order by block_row_number) as value_partition
|
||||
FROM staging2.IHTBT30_BT30_Test_Res_4_Block
|
||||
where block_row_number > 2
|
||||
ORDER BY block_row_number ASC
|
||||
) as q) b where a.block_row_number=b.block_row_number;
|
||||
|
||||
@@ -734,14 +717,14 @@ update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
mode=b.column11
|
||||
from staging2.IHTBT30_BT30_Test_Res_1_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
Humidity_RH=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_1_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
@@ -749,14 +732,14 @@ update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
mode=b.column11
|
||||
from staging2.IHTBT30_BT30_Test_Res_2_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
Humidity_RH=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_2_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
@@ -764,14 +747,14 @@ update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
mode=b.column11
|
||||
from staging2.IHTBT30_BT30_Test_Res_3_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
Humidity_RH=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_3_Block b
|
||||
where b.block_row_number =3 and condition=b.column2;
|
||||
|
||||
@@ -779,14 +762,14 @@ update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set date=b.column4,
|
||||
location=b.column7,
|
||||
--time=b.column9,
|
||||
mode=b.column10
|
||||
mode=b.column11
|
||||
from staging2.IHTBT30_BT30_Test_Res_4_Block b
|
||||
where b.block_row_number =2 and condition=b.column2;
|
||||
|
||||
update staging2.IHTBT30_BT30_Test_Condition_Block
|
||||
set Wind_Velocity_Km_hr=b.column5,
|
||||
Ambient_Temperature_C=b.column7,
|
||||
Humidity_RH=b.column9
|
||||
Humidity_RH=b.column10
|
||||
from staging2.IHTBT30_BT30_Test_Res_4_Block b
|
||||
where b.block_row_number=3 and condition=b.column2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user