schaapiee
3/22/2007 2:58:00 PM
On Mar 22, 3:02 am, "Uri Dimant" <u...@iscar.co.il> wrote:
> In SQL Server 2000 you can do something like that
>
> create table test (
> c1 char(1),
> c2 int
> )
>
> insert into test values('A',10)
> insert into test values('A',8)
> insert into test values('A',7)
> insert into test values('B',12)
> insert into test values('B',8)
> insert into test values('B',6)
> insert into test values('C',1)
>
> SELECT * FROM test E
> WHERE (
> SELECT COUNT(*) FROM test
> WHERE c1 = E.c1
> AND c2 < E.c2
> ) <= 1
> ORDER BY c1, c2 DESC
>
> "schaapiee" <drobertmil...@yahoo.com> wrote in message
>
> news:1174487722.741212.76630@n76g2000hsh.googlegroups.com...
>
>
>
> >I want to grab the Min of a set of numbers, which works out fine. How
> > can I grab the second lowest number?
>
> > I tried to run another Min and exclude items from first Min,
> > logically this would exclude the lowest and the second lowest would
> > now be the first lowest, but it doesnt work.
>
> > Does anyone have any ideas on how to write this?- Hide quoted text -
>
> - Show quoted text -
If I change the count to <= 2 it returns the top 2 values, but only if
there are two items to begin with.
I have a c2 that returns 5 lines, and so these are excluded from the
results. Any ideas?