[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread rudy
> If you do Union them, does that still allow you to 'order by' the sub queries no a query that includes a UNION is called a "fullselect" and its components are called "subselects" the subselects are not allowed to have an ORDER BY, only the fullselect sometimes you will see this -- select

[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread Stephen Caudill
If you do Union them, does that still allow you to 'order by' the sub queries, or does it just undo the 'order by'. I'm not sure if that's even the best way, just trying to understand. I definitely don't get Rudy's example below. Sorry to be so thick. -Stephen http://www.mechavox.com On Tuesd

[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread Stephen Caudill
Thanks Guys! I guess I should have noted that I'm using SQL server. I really liked the idea of your first solution, Rudy (NULLS LAST), but it isn't supported in MS SQL Server. Right now I'm leaning toward either splitting it into multiple SQL statements or using the sort option to put the n

[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread Furry, Tim
rudy suggested: select contactID, (fname + ' ' + lname) as fullname, email from contacts where active = 1 order by case when lname is null then '999' else lname end , case when fname is null then '999' else fname end , email however, it's a nice techni

[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread rudy
> "select id, fname + space(1)+isnull(lname,'') as fullname from tablename > where lname is not null > union all > select id, fname + space(1)+isnull(lname,'') as fullname from tablename > where lname is null" hi elan i think i know where you're going with that, but you would have to do somethin

[wdvltalk] Re: Sorting ADO recordsets

2003-07-22 Thread elan
Hi Stephen, You can use simple union all . Ex. "select id, fname + space(1)+isnull(lname,'') as fullname from tablename where lname is not null union all select id, fname + space(1)+isnull(lname,'') as fullname from tablename where lname is null" Thanks, Elan > I've got one that's really

[wdvltalk] RE: Sorting ADO recordsets

2003-07-21 Thread Paul Larue
The first thing I'm thinking of is making 2 queries. One with WHERE fname <> "" and another one with WHERE fname = "". Thw first one would return everything with a 'name' and the second one without the names. It seems "rude" but I can't think of something else for the mo'. I'm sure somebody on th

[wdvltalk] Re: Sorting ADO recordsets

2003-07-21 Thread rudy
you forgot to mention which database, so i shall assume your database is standards compliant and supports the CASE structure select contactID, (fname + ' ' + lname) as fullname, email from contacts where active = 1 order by case when lname is null then '999' else lname e