Question : SQL data sorting

Hi,

i have a simple table with 4 rows, 2 numeric, 2 varchar.

varchar1, varchar2, num1, num2

the data within them is kinda mixed up, and i need to sort it. for example

apples, pears, 10, 20
pears, apples, 15, 15

what i need to do is sort it so that apples and pears are both in the same collums, like this:

apples, pears, 10, 20
apples, pears 15, 15

the sorting of the varchar colums needs to be done alpabetically.

i have thought that i could do this by making the database relational by moving the varchar vales into another table, and then giving them numberic ID's to sort them, but im sure there is a much simpler way.

any ideas?

Answer : SQL data sorting

And I missed it again :-)

OK, hows this?

select field1, field2, count(*)
from (select field1, field2, field3, field4 from yourtable where field1 <= field2
union all
select field2, field1, field4, field3 from yourtable where field1 > field2
) a
group by field1, field2
Random Solutions  
 
programming4us programming4us