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
 General SQL Server Forums
 New to SQL Server Programming
 Some Query Puzzle

Author  Topic 

surya_rakanta
Starting Member

19 Posts

Posted - 2008-07-30 : 20:03:38
Dear All,

I have the sample data as follows :

SeqNo Code
1 AA
2 AA
3 AA
4 BB
5 CC
6 DD
7 AA
8 AA
9 CC
10 CC
Is it possible, using query to get :
Code SeqNo(Max) SeqNo(Min)
AA 3 1
BB 1 1
CC 5 5
DD 6 6
AA 8 7
CC 10 9
Thanks for your insight and assistance.
Rgds
Eka S.

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-07-30 : 20:31:20
Here are three free online tutorials to learn SQL:
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

These are the primary Microsoft SQL Server References:
SQL Server 2000 Books Online
http://msdn2.microsoft.com/en-us/library/aa257103(SQL.80).aspx
SQL Server 2005 Books Online
http://msdn2.microsoft.com/en-us/library/ms130214.aspx




CODO ERGO SUM
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-30 : 21:04:03
http://www.sqlteam.com/article/detecting-runs-or-streaks-in-your-data

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

surya_rakanta
Starting Member

19 Posts

Posted - 2008-07-30 : 22:34:01
It's impossible isn't it :)
Rgds
Eka S.

God didn't do this, Anna, WE did.
— Robert Neville in I am Legend.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-31 : 07:35:55
again:

http://www.sqlteam.com/article/detecting-runs-or-streaks-in-your-data

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-31 : 09:08:24
Are you using sql 2005?
Go to Top of Page

surya_rakanta
Starting Member

19 Posts

Posted - 2008-07-31 : 20:50:55
Are you using sql 2005?
----
Nope, SQL 2000. But solved in SQL 2005 will be file

Tried the running-streak sample, problem is, the second group of code AA is get grouped to first AA.

Rgds
Eka S.


Here is a thing about the future :
every time you look at it, it changes.
Because you look at it, that changes everything else.
-Frank Cadillac in NEXT
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-31 : 22:00:49
quote:
Originally posted by surya_rakanta

Are you using sql 2005?
----
Nope, SQL 2000. But solved in SQL 2005 will be file

Tried the running-streak sample, problem is, the second group of code AA is get grouped to first AA.




Then you didn't do it right ... your situation is exactly the same, make sure you followed the article closely. Also -- Post what you've tried.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -