Sort question on two fields 
Author Message
 Sort question on two fields

In code, how would I sort data on two different fields not next to each
other?

If I have the following:

Select fld1,fld2 from tblmain order by fld1 and fld2

It sorts on both fields at the same time. How do I sort on fld2 first then
sort it on fld1? I want it sorted by fld1 within a fld2 sort.

Like:
fld1   fld2
1       A
2       A
3       A
1       B
2       B

rather than:

fld1   fld2
1       A
1       B
2       A
2       B
3       A

Thanks

Scott



Mon, 27 Jun 2005 05:55:34 GMT  
 Sort question on two fields
You might try:

Select fld1,fld2 from tblmain order by fld2, fld1


Quote:
> In code, how would I sort data on two different fields not next to each
> other?

> If I have the following:

> Select fld1,fld2 from tblmain order by fld1 and fld2

> It sorts on both fields at the same time. How do I sort on fld2 first then
> sort it on fld1? I want it sorted by fld1 within a fld2 sort.

> Like:
> fld1   fld2
> 1       A
> 2       A
> 3       A
> 1       B
> 2       B

> rather than:

> fld1   fld2
> 1       A
> 1       B
> 2       A
> 2       B
> 3       A

> Thanks

> Scott



Mon, 27 Jun 2005 05:59:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sorted Order of two Fields

2. newbie sort two fields in database

3. Sorting an array on two fields

4. search and return sorted by two fields

5. sorting by two fields

6. Two CreateTableDef and counter field questions

7. Sort fields question

8. Having trouble accessing single field key with two concatenated fields

9. Sorting with two parameters?

10. sorting a two dimensional array?

11. Sorting two dimensional array

12. Sorting with two parameters?

 

 
Powered by phpBB® Forum Software