I have a table T1 with below data
Domain;Mode;Channel;KPI;Value;AvgTm;Rounded_Time
USD;Manual;P1;consolidateUSD;20;2;11/14/2015 12:15:00
USD;Manual;P1;consolidateUSD;10;4;11/14/2015 12:30:00
USD;Manual;P1;consolidateUSD;10;2;11/14/2015 12:45:00
USD;Manual;P1;consolidateUSD;20;4;11/14/2015 13:00:00
DKT;Auto;P2;consolidateDKT;5;4;11/14/2015 12:15:00
DKT;Auto;P2;consolidateDKT;5;4;11/14/2015 12:30:00
DKT;Auto;P2;consolidateDKT;5;4;11/14/2015 12:45:00
DKT;Auto;P2;consolidateDKT;5;4;11/14/2015 13:00:00
I need to aggregate data based on "Rounded_Time" and I must get the SUM of "value" and AVG of "AvgTm" and pump into another table T2. This script will be scheduled hourly. So, next time, it must not pick earlier data.
output T2 table has
Domain;Mode;Channel;KPI;Value;AvgTm;Rounded_Time
USD;Manual;P1;consolidateUSD;60;3;11/14/2015 13:00
DKT;Auto;P2;consolidateDKT;5;4;11/14/2015 13:00
I am not able to get the output properl. I tried the below. I am new to SQL .Please help.
select * from T1
where Rounded_Time interval 60 and SUM(Value) and AVG(AvgTm)
group by Domain,Mode,Channel,KPI