Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I Want A SQL Query.
Input :
VB
1   A
2
3
4
5
6
7
8
9
10
11
12  B
13
14
15
16  C
17
18
19
20
21
22
23
24
25
26
27  D
28
29
30
31
32
33
34
35
36
37
38
39  E
40




Output :
VB
1   A
2   A
3   A
4   A
5   A
6   A
7   A
8   A
9   A
10  A
11  A
12  B
13  B
14  B
15  B
16  C
17  C
18  C
19  C
20  C
21  C
22  C
23  C
24  C
25  C
26  C
27  D
28  D
29  D
30  D
31  D
32  D
33  D
34  D
35  D
36  D
37  D
38  D
39  E
40  E


I Want This Output In A Single Query. (No Cursor.)

Please Help.
Posted

1 solution

There are no "consecutive rows". The data stored in a table is abstracted from any concrete order. The order only appears as a result of some query, and then you can control it, say, using SQL ORDER BY clause: http://technet.microsoft.com/en-us/library/ms188723%28v=sql.90%29.aspx[^].

Therefore, the question makes no sense. You can probably get some practical advice if you explain your ultimate goal.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900