So, I have to calculate total Type
A where From
& To
in between From
& To
Type
B based on ID
. I can't describe it in good words, so this is the example and my expected result (Column Count
) :
ID | Type | From | To | Count ------------------------------- 100 | A | 10 | 14 | 100 | A | 16 | 18 | 100 | B | 12 | 14 | 1 100 | B | 11 | 13 | 1 100 | B | 17 | 18 | 1 120 | A | 5 | 10 | 120 | A | 12 | 14 | 120 | A | 18 | 20 | 120 | A | 18 | 20 | 120 | A | 22 | 24 | 120 | B | 30 | 32 | 0 120 | B | 19 | 20 | 2 120 | B | 10 | 14 | 1
Anybody can help ? I'm expecting something similar like COUNT OVER or RANK OVER without GROUP BY because the table above is not original table, its from another subquery..
https://stackoverflow.com/questions/67362705/sql-query-how-to-get-count-where-current-row-values-in-between-previous-rows May 03, 2021 at 10:01AM
没有评论:
发表评论