Hi,
- Got a table with some rows based on each date, Employee, Channel and their work hours. Have to Remove Adjacent duplicates for Col1,Col2 and Col3. Where as Min of Col4 need to be used in the row and Sum of Col5 have to be calculated.
- Have to derive the input TableA to the Output mentioned below. (Considering only adjacent rows and not for the whole month)
- I had done a recent query to remove the adjacent duplicates - But stucks with the grouping. Still can able to handle it using Cursors or lopping - Is there any other way to use the query to fetch the output. Since my number of rows will be more than lacs.
TableA:
[Col1] [Col2] [Col3] [Col4] [Col5]
M1 CH1 Jun18 1000 60
M1 CH1 Jun18 1060 600
M1 CH1 Jun18 1660 120
M2 CH1 Jun18 1500 240
M2 CH1 Jun18 1740 60
M1 CH1 Jun18 1800 180
M2 CH1 Jun18 1980 60
M2 CH1 Jun18 2040 540
M1 CH1 Jul18 1000 600
M1 CH1 Jul18 1600 60
M2 CH1 Jul18 1660 120
M2 CH1 Jul18 1780 90
Output:
[Col1] [Col2] [Col3] [Col4] [Col5]
M1 CH1 Jun18 1000 780
M2 CH1 Jun18 1500 300
M1 CH1 Jun18 1800 180
M2 CH1 Jun18 1980 600
M1 CH1 Jul18 1000 660
M2 CH1 Jul18 1660 210