Home » SQL & PL/SQL » SQL & PL/SQL » Filter data
Filter data [message #205835] Mon, 27 November 2006 19:10 Go to next message
juicyapple
Messages: 92
Registered: October 2005
Member
I have a table with data

SeqNo Name
----- ----
1 R
2 P
3 Q
4 P
5 P
6 S
7 Q
8 S
9 Q
10 F

If my current SeqNo is 7 and I want to count how many P and S above SeqNo 4 (counter stop when it meet Name except P and S)

Is there any simple query which can work?

Thanks.
Re: Filter data [message #205836 is a reply to message #205835] Mon, 27 November 2006 19:12 Go to previous messageGo to next message
juicyapple
Messages: 92
Registered: October 2005
Member
resend (typo in previous send) :

If my current SeqNo is 7 and I want to count how many P and S above SeqNo 7 (counter stop when it meet Name except P and S)
Re: Filter data [message #205899 is a reply to message #205836] Tue, 28 November 2006 01:45 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Just find the highest seqnence number smaller than 7 that is not a P or S.

(untested)
SELECT 7 - (max(seqno)+1)
FROM table
WHERE seqno <7
AND name NOT IN ('P','S')
Previous Topic: convert 1 row into multiple rows
Next Topic: Desing issue - Please tell me if i am right
Goto Forum:
  


Current Time: Sat Dec 10 05:08:02 CST 2016

Total time taken to generate the page: 0.13454 seconds