Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum and Group By

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I'm trying to structure a query that will let me get the sum and group by a time period.

Table has Account Number, Amount Purchased, Fiscal Year, Fiscal Period, Fiscal Week, and Date. It also has a few more fields, but these are the ones I'm concerned with.

Code:
SELECT DISTINCT Accounts.FscPeriodID, Sum(Accounts.AmountPurchased) AS SumOfAccounts, FROM AcctTable WHERE (((Accounts.AcctNo)="1241113") And ((Accounts.FscYearID)=2013))
GROUP BY Accounts.FscPeriodID, ORDER BY Accounts.FscPeriodID;

When I run it, it returns a row for each Date. I'm wanting it to return a total for each Fiscal Period.

I'd appreciate someone pointing me in the right direction. :)


Rob
Just my $.02.
 
return a total for each Fiscal Period"
[tt]
SELECT FiscalPeriod, Sum(AmountPurchased) AS SumOfAccounts
FROM AcctTable
GROUP BY FiscalPeriod[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top