Group By Qtr

A

acss

I cant figure out how to group my records by quarters or months.Is there a
special query to otain these results? My current SQL is pretty basic using
two tables as the following:

SELECT VendorInv.EnterDate, VendorInv.InvDesc, VendorInv.InvCode,
VendorInv.InvAmt
FROM Vendor INNER JOIN VendorInv ON Vendor.VendorID = VendorInv.VendorID;

The format in EnterDate field is 01/01/2008 yet i am lost on the
grouping.Can this be done?
 
J

Jerry Whittle

It can be done readily in a Report. Sort and Group on the EnterDate field in
the report. In the properties you can choose to group by day, week, month,
and quarter.
 
K

KARL DEWEY

You say the format in EnterDate field is 01/01/2008 but did not say if it was
a DateTime datatype field.
Below assumes that it is --
SELECT Format([VendorInv].[EnterDate], "yyyy q") As [Vendor QTR],
VendorInv.InvDesc, VendorInv.InvCode, Sum([VendorInv].[InvAmt] AS Amount
FROM Vendor INNER JOIN VendorInv ON Vendor.VendorID = VendorInv.VendorID;
GROUP BY Format([VendorInv].[EnterDate], "yyyy q"), VendorInv.InvDesc,
VendorInv.InvCode;
 

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

Similar Threads


Top