ORDER BY
Month(DateField),
Year(DateField),
AlphaField
?
(or you could use DatePart() instead of Month() and Year())
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Keener, Bradley P" <bradley.keener@e...>
Subject: [sql_language] Unusual ORDER BY
: I am ordering a recordset by two fields. The first field is a date in
: Julian format and the second field is a single letter. The problem I have
: is that I don't need to order by the entire date, I really only need to
: order by the year and month and then order by the second field. In other
: words the for each month and year of the first field, the second field
must
: be in alphabetical order, irregardless of what day is in the first date.
So
: I really am only interested in ordering first by the first 6 digits of the
8
: digit date field and then ordering by the second field.
:
: For example:
:
: Field 1 Field 2
: 20020620 B
: 20020621 A
: 20020622 B
: 20020701 B
: 20020702 A
:
: I need this brought back as
:
: Field 1 Field 2
: 20020621 A
: 20020620 B
: 20020622 B
: 20020702 A
: 20020701 B
:
: Can this be done with a SQL statement? Is there a way to order by only
the
: first 6 characters of a field or refine the original query inside itself?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~