Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting results from query, unique but not?

Status
Not open for further replies.

bind

IS-IT--Management
Dec 13, 2004
25
Hello,

I'm trying to just return the last number in this row but unique. So for example in the row "number" below, I just want 1180237, 2063287 and 3047576 to return on the query, is there any way of returning the top unique number for all numbers contained in a row?

Not sure how else to ask the question, hopefully it makes sense.

Thank you

|number|
'1180237'
'1180236'
'1180235'
'1180234'
'2063287'
'2063286'
'2063285'
'2063284'
'2063283'
'2063282'
'2063295'
'2063294'
'2063293'
'2063292'
'2063291'
'2063290'
'2063289'
'2063288'
'2063304'
'2063303'
'2063302'
'2063301'
'2063300'
'2063299'
'2063298'
'2063297'
'2063296'
'1180233'
'1180232'
'1180231'
'3047576'
'2063280'
'2063281'
'3047575'
'3047574'
 
r937,

Thanks for your reply but that's not yielding the result I'm looking for.

Cheers.
 
Perhaps this is what you are looking for:
Code:
SELECT number  FROM daTable
MINUS
SELECT number-1  FROM daTable
 
PS:
Sorry; MINUS is not yet available.
I had another database in mind ....
:-(
 
Assuming that you want the highest numbers from all consecutive sequences of numbers then this seems to work for me
Code:
SELECT number 
  FROM datable
 WHERE NOT number IN ( SELECT number
                         FROM datable 
                        WHERE number+1 IN ( SELECT number
                                              FROM datable
                                          )
                   )


Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top