Sorting subsets - is this even possible?

Sorting subsets - is this even possible?

Post by Ruur » Sun, 25 Nov 2001 00:53:59



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?

Post by Umachandar Jayachandra » Sun, 25 Nov 2001 01:29:22


    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
( Please reply only to newsgroup. )

 
 
 

Sorting subsets - is this even possible?

Post by Chris Haugne » Sun, 25 Nov 2001 04:08:35


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?

Post by Ruur » Sun, 25 Nov 2001 01:48:11


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

 
 
 

1. I am getting duplicate records, I mean everything is duplicate even Access record number

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

2. Multiple Database Query

3. Use of MSDE (subset of MS SQL) possible?

4. Local Identifier Property

5. How to Sort Subset of Hierarchical Query

6. PL/SQL problem

7. Exp/Imp subset of table possible?

8. Missing overflow on GA box

9. Is this even possible....

10. join problem - is this even possible?

11. Is This Even Possible?

12. Is this even possible?

13. Progressbar w/ updatebatch ADO, is this even possible?