Hi,
you probably meant
SELECT Format$([TestDate],"mmm-yy") AS MonthYear,
Sum(tblTest.TestCurr) AS TotalAmount
FROM tblTest
GROUP BY Format$([TestDate],"mmm-yy")
ORDER BY LAST(TestDate)
or
SELECT Format$([TestDate],"mmm-yy") AS MonthYear,
Sum(tblTest.TestCurr) AS TotalAmount
FROM tblTest
GROUP BY Format$([TestDate],"mmm-yy"), Format$([TestDate],"yy-mmm")
ORDER BY Format$([TestDate],"yy-mmm")
since we need to either aggregate (first example) or Group (second example)
on the expressions we wish to use, that is a technical requirement of total
queries, that is nice to add TestDate in the Groups, we could then re-use
it, but that would also produce no useful grouping (at least, not "by month"
anymore) if there are more than one single TestDate by desired group
(month-year).
The second example does not break, explode, previously existing groups, and
allow us to re-use the new expression in the sort; the first example,
probably more efficient, decided to keep a random value of TestDate, for
each group, and sort on that value, again, no group modified in itself.
Vanderghast, Access MVP
Ken Snell said:
SELECT Format$([TestDate],"mmm-yy") AS MonthYear, Sum(tblTest.TestCurr) AS
TotalAmount
FROM tblTest
GROUP BY Format$([TestDate],"mmm-yy"), [TestDate]
ORDER BY [TestDate];
--
Ken Snell
<MS ACCESS MVP>
Liz Hansen said:
Hi,
This works. Thanks.
However, another problem popped up. If I try to sort my new month grouping
it will sort alphabetically, not by "time"... So Apr-03 would come before
Jan-03.
Is there a way around this?
Thanks,
Liz,
"Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message
SELECT Format$([TestDate],"mmm-yy") AS MonthYear,
Sum(tblTest.TestCurr)
AS
TotalAmount
FROM tblTest
GROUP BY Format$([TestDate],"mmm-yy");
--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it
impossible
for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me
with