Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Problem

Status
Not open for further replies.

mustang33

Programmer
Nov 22, 2002
1
US
I have a table containing 2 names – call
them Name1 & Name2. I need to list both
names in a single column in a report and
sort them as if they are the same field.
Problem is if I sort on the two names,
(remember, they are different fields), Name1
is sorted but the corresponding Name2 always
appears directly after it.
For instance -
Row 1 contains: Name1=Smith, Name2=Jones
Row 2 contains: Name1=Anderson, Name2=Brown
I want the result to be:
Anderson
Brown
Jones
Smith

But I get:
Anderson
Brown
Smith
Jones

CR ver. 7.5.
Any thoughts?
 
I'd combine these fields into one field, using a Union. This can be more efficiently done on the database, but you can do it in Crystal too:

Build the report omitting the name2 field.

Copy the SQL from Database->Show SQL Query

add the word UNION ALL on a new line under the SQL

Now paste the copied SQL below the word union

In the pasted version, change name1 to name2

Now sort the rows by name1 (that will be the only name column now).

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top