| Author |
Topic |
|
kartikkumar84
Starting Member
7 Posts |
Posted - 2009-07-15 : 06:45:37
|
| Hi I am relatively new to SQL and databases. I wanted some information from a database at work. I have result set (after running and sorting a query) with more than 40000 rows.. I am pasting a prtion of it.A B10000050 210000050 710000051 710000051 210000055 110000055 710000056 110000056 710000057 110000057 910000058 110000058 910000058 310000059 110000059 910000059 9...... .From this result set, I want to list all entries in Row A for which Row A = Row Band Row A+1 = Row B+1As an example, please see the last two rows from the data set I have pasted. I want all such entries listed. Thanks in advance. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-15 : 06:55:55
|
| select a,b from your_tablegroup by a,bhaving count(*)>1MadhivananFailing to plan is Planning to fail |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-07-15 : 07:13:28
|
| select a,b from (select row_number()over(partition by a,b order by a ) as rid , a, b from tablename)s where rid >1 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-15 : 07:18:46
|
quote: Originally posted by bklr select a,b from (select row_number()over(partition by a,b order by a ) as rid , a, b from tablename)s where rid >1
It seems OP is using SQL Server 2000 (from the title of the thread) where your query wont workMadhivananFailing to plan is Planning to fail |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-07-15 : 07:20:16
|
| deleted |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-07-15 : 07:21:16
|
| k Thanks,Madhivanani haven't seen the titlehi, karthik it will works 2005 and above........ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-15 : 07:21:22
|
quote: Originally posted by russell deleted
What did you post?MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-15 : 07:22:26
|
quote: Originally posted by bklr k Thanks,Madhivanani haven't seen the titlehi, karthik it will works 2005 and above........
No Problem MadhivananFailing to plan is Planning to fail |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-07-15 : 07:22:37
|
same solution as bklr |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-15 : 07:24:05
|
quote: Originally posted by russell same solution as bklr 
Dont delete the script. You can edit your reply to include this after the query MadhivananFailing to plan is Planning to fail |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-07-15 : 07:25:35
|
quote: Originally posted by madhivanan
quote: Originally posted by russell same solution as bklr 
Dont delete the script. You can edit your reply to include this after the query MadhivananFailing to plan is Planning to fail
lol |
 |
|
|
kartikkumar84
Starting Member
7 Posts |
Posted - 2009-07-15 : 08:27:38
|
| Thank You!! |
 |
|
|
|