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.
| Author |
Topic |
|
mugen2005
Starting Member
16 Posts |
Posted - 2011-12-08 : 08:00:27
|
| Checking row above for a count, is this possible? I want to count the X’s under activity ONLY if the row above is a B. Looking at the sample data there are 3 X’s, however with the query I would like to return only the 2 X’s which have ‘B’ about it. Any help would be appreciated, Thank you. ID activity1 A2 B3 X4 A5 A6 B7 A8 X9 B10 X11 A12 A |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-08 : 08:06:12
|
[code]select *from table t1 inner join table t2 on t1.ID = t2.ID - 1where t1.activity = 'B'and t2.activity = 'X'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mugen2005
Starting Member
16 Posts |
Posted - 2011-12-08 : 09:01:16
|
| worked perfect, thank you |
 |
|
|
|
|
|