i try to write a sql order like this subject: GROUP BY with MAX(DATE). But harder For Example:
column1 column2 column3 column4 column5
12 1 A1 1 1
0 1 A1 1 2
18 1 A1 1 3
20 1 A1 2 1
23 1 A1 2 2
4 1 B1 1 1
7 1 B1 1 2
12 1 B1 1 3
17 1 B1 2 1
0 1 B1 2 2
#\n just for clarity
13 2 A1 1 1
25 2 A1 1 2
24 2 A1 1 3
25 2 A1 2 1
0 2 A1 2 2
13 2 B1 1 1
0 2 B1 1 2
24 2 B1 1 3
25 2 B1 2 1
0 2 B1 2 2
#\n just for clarity
7 3 A1 1 1
10 3 A1 1 2
14 3 A1 1 3
15 3 A1 2 1
18 3 A1 2 2
7 3 B1 1 1
10 3 B1 1 2
14 3 B1 1 3
15 3 B1 2 1
18 3 B1 2 2
for each group in column2 for each group in column3, collect the max of column4 of max of column5 but ignore if column1 = 0 (if the max is 0 take the second max)
in this example i desire this result:
column1 column2 column3 column4 column5
23 1 A1 2 2
17 1 B1 2 1
25 2 A1 2 1
25 2 B1 2 1
18 3 A1 2 2
18 3 B1 2 2
Could you help me please