Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Group rows until next occurrence

Author  Topic 

danielc
Starting Member

49 Posts

Posted - 2014-10-27 : 16:25:30
Hi,

I have bulk imported a text file into a table that contains two columns (Line, Key). What I would like to due is group the rows that follow Callsign. The data below is what I have in the table right now.

Line |Key |
-------------------------------------------------------|
Callsign: K201DU |Null |
Contour: F(50,50) dBu: 30 |Null |
81620 81631 81632 81645 81649 81655 81657 81658 |Null |
Contour: F(50,50) dBu: 31 |Null |
81620 81631 81632 81645 81649 81655 81657 81658 |Null |
Callsign: K201DX |Null |
Contour: F(50,50) dBu: 30 |Null |
97813 97835 97862 99323 99324 99329 99348 99360 |Null |
99361 99362 99363 |Null |
Contour: F(50,50) dBu: 31 |Null |
97835 97862 99323 99324 99329 99348 99360 99361 |Null |
99362 99363 |Null |


The results i'm hoping to get is as follows:

Line |Key|
----------------------------------------------------|
Callsign: K201DU |1 |
Contour: F(50,50) dBu: 30 |1 |
81620 81631 81632 81645 81649 81655 81657 81658 |1 |
Contour: F(50,50) dBu: 31 |1 |
81620 81631 81632 81645 81649 81655 81657 81658 |1 |
Callsign: K201DX |2 |
Contour: F(50,50) dBu: 30 |2 |
97813 97835 97862 99323 99324 99329 99348 99360 |2 |
99361 99362 99363 |2 |
Contour: F(50,50) dBu: 31 |2 |
97835 97862 99323 99324 99329 99348 99360 99361 |2 |
99362 99363 |2 |

Thanks in advance for your help...

Daniel

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-28 : 08:56:42
Two questions:

1. your Key column is all nulls. Is that correct?
2. What do you mean by "follow Callsign"? I cannot see any ordering column. Remember that tables are Sql Servers way of representing relations, which are sets and have no implicit ordering.
Go to Top of Page
   

- Advertisement -