Unix Technical Forum

Sorting in query with Union

This is a discussion on Sorting in query with Union within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I am attempting to write a complex query to group sets of data. I have my query working ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:31 PM
Karen Bailey
 
Posts: n/a
Default Sorting in query with Union

Hi,

I am attempting to write a complex query to group sets of data. I have my
query working correctly, but i ran into a problem with sorting.

I want to sort my query by a string field.

Is there a way around sorting using a field other than numeric of a query
containing a union?

Thanks,

Karen


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:31 PM
charliek
 
Posts: n/a
Default Re: Sorting in query with Union

On Fri, 24 Oct 2003 13:10:51 -0400, "Karen Bailey"
<karenb@centurysystems.net> wrote:

>Hi,
>
>I am attempting to write a complex query to group sets of data. I have my
>query working correctly, but i ran into a problem with sorting.
>
>I want to sort my query by a string field.
>
>Is there a way around sorting using a field other than numeric of a query
>containing a union?
>
>Thanks,
>
>Karen
>


You could do something like:

use northwind

(
select city
from customers
union
select city
from employees
)
order by city desc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:02 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com