Closed. This question needs details or clarity . It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post .
Closed 14 hours ago.
Improve this question
I have a table Tbl_A
there is only one column Id
. There are multiple numbers like as below mention. I want to get count that how many times 1 is occurring in continues three times.
Data :-
id
1
1
2
2
2
1
1
1
3
1
1
1
create table Tbl_A (id int);
insert into Tbl_A
select 1 Union All
select 1 Union All
select 2 Union All
select 2 Union All
select 2 Union All
select 1 Union All
select 1 Union All
select 1 Union All
select 3 Union All
select 1 Union All
select 1 Union All
select 1 ;
Expected Output :- 2 (Because 1 is only 2 times occurring in continues three times )
I have tried with Lag, Lead also with Rank but no luck.
1条答案
按热度按时间g6ll5ycj1#
As much deterministic sorting it can get for TBL_A to order by the physical location of a row.