Problems with sorting

S

Sue

I have 3 date fields. For convenience, I'll call them A, B, & C. They're all
in mm/dd/yyyy format. I want to sort them in this fashion:

C should be in descending order.
If C is null, the secondary sort should be in descending order by B.
If B is null, the tertiary sort should be in descending order by B.

I simply can't get it to sort correctly.

Ideas?

Thanks.
 
A

Allen Browne

Try something like this in the ORDER BY clause of your query:
IIf([C] Is Null, IIf( Is Null, [A], ,), [C])
 
S

Sue

PERFECT!
Thanks.
--
Thanks for your time!


Allen Browne said:
Try something like this in the ORDER BY clause of your query:
IIf([C] Is Null, IIf( Is Null, [A], ,), [C])

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Sue said:
I have 3 date fields. For convenience, I'll call them A, B, & C. They're
all
in mm/dd/yyyy format. I want to sort them in this fashion:

C should be in descending order.
If C is null, the secondary sort should be in descending order by B.
If B is null, the tertiary sort should be in descending order by B.

I simply can't get it to sort correctly.

Ideas?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top