## Sorting subsets - is this even possible?

### Sorting subsets - is this even possible?

Hi all,

I have a table with multiple columns in it.
Currently I sort them by:  ORDER BY (COL1 - COL2)

However, I need to sort only a part of the table like that. Therefor I would
like to do:

SELECT x, y, z from table ORDER BY
CASE
WHEN (y<z) then 'y-z'
ELSE 'x'
END

However, this does not seem to work. Is this possible? Can sql server (2k)
sort subsets of data??

Thanks,
Ruurd

### Sorting subsets - is this even possible?

CASE
WHEN (y<z) THEN y-z
ELSE x
END

Does this do it?? You were sorting by the expression 'y-z' & 'x' not the
value.

--
Umachandar Jayachandran
SQL Resources at http://www.umachandar.com/resources.htm

### Sorting subsets - is this even possible?

try a different approach.

select x, y, z, 'OrderBy' = case when y < z then 0 else 1 end
from table
order by [OrderBy]

Chris

> Hi all,

> I have a table with multiple columns in it.
> Currently I sort them by:  ORDER BY (COL1 - COL2)

> However, I need to sort only a part of the table like that. Therefor I
would
> like to do:

> SELECT x, y, z from table ORDER BY
>     CASE
>         WHEN (y<z) then 'y-z'
>         ELSE 'x'
>     END

> However, this does not seem to work. Is this possible? Can sql server (2k)
> sort subsets of data??

> Thanks,
> Ruurd

### Sorting subsets - is this even possible?

brilliant..
that did the trick.. many thanks

> try a different approach.

> select x, y, z, 'OrderBy' = case when y < z then 0 else 1 end
>     from table
> order by [OrderBy]

> Chris

> > Hi all,

> > I have a table with multiple columns in it.
> > Currently I sort them by:  ORDER BY (COL1 - COL2)

> > However, I need to sort only a part of the table like that. Therefor I
> would
> > like to do:

> > SELECT x, y, z from table ORDER BY
> >     CASE
> >         WHEN (y<z) then 'y-z'
> >         ELSE 'x'
> >     END

> > However, this does not seem to work. Is this possible? Can sql server
(2k)
> > sort subsets of data??

> > Thanks,
> > Ruurd

I have a database program in VB6 service pack 3 with a Access 2000 database
file
and using the microsoft active data objects 2.0 library.

I am getting duplicate records, I mean everything is duplicate
even the Access Record number. What I mean is if you open the database file
in Access 2000
the left column is then record number access uses to store your line item
and I see two record numbers with the same and somtimes different fiels
values.

So has anyone experienced this and does the
microsoft active data objects 2.5 library fix this?

Thank You
Bill A