Here is a 2 column table called HIGHVALS. I am looking for TSQL to count the number of higher highs in column B. Row 1 starts the counting at 1. At row 2 the count is 2 because 1525.34 is > than 1520.08. Rows 3 and 4 do not contribute to the count because they are both < 1525.34 the last highest value. Row 5 contributes to the count because 1543.47 is > 1525.34 the last highest value. The end result of the counting should be 14.
A, B
1, 1520.08
2, 1525.34
3, 1519.99
4, 1525.27
5, 1543.47
6, 1545.25
7, 1545.78
8, 1552.48
9, 1556.27
10, 1556.77
11, 1556.39
12, 1563.32
13, 1563.62
14, 1560.7
15, 1557.25
16, 1561.56
17, 1558.71
18, 1557.74
19, 1564.91
20, 1563.95
21, 1564.07
22, 1570.28
23, 1570.57
24, 1573.66
Adding one last item to this. There are multiple instances of the above in the table. Column C provides the unique key to group by. Could I get a little more guidance based on the addition of Column C? Same requirements as before, count only the higher highs in column B, but now group by column C.
COL_A,COL_B,COL_C
21037,1345.00,21037
21038,1341.29,21037
21039,1357.7,21039
21040,1357.26,21039
21041,1365.36,21039
21042,1375.26,21039
21043,1380.39,21039
21044,1376.51,21039
21045,1362.34,21045
21046,1351.53,21045
21047,1343.98,21045
21048,1363.13,21048
21049,1389.18,21048
21050,1391.74,21048
21051,1387.16,21048
21052,1385.03,21048
21053,1375.13,21048
21054,1394.16,21048
21055,1399.63,21048
21056,1407.14,21048
21057,1404.14,21048
21058,1405.95,21048
21059,1405.98,21048
21060,1405.87,21048
21061,1410.03,21048
21062,1407.73,21048
21063,1417.43,21048
21064,1418.71,21048
21065,1418.13,21048
21066,1426.68,21048
21067,1416.12,21048
21068,1413.49,21048
21069,1413.46,21048
21070,1416.17,21048
21071,1413.63,21048
21072,1413.95,21048
21073,1410.08,21073
I appreciate everyone's suggestions.