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!

Group by week

Status
Not open for further replies.

Boomn4x4

IS-IT--Management
Oct 19, 2006
6
0
0
US
I have a simple count querey how do I group it by 7 day weeks of the year? Sun - Sat
 
Can you show the query. It'll make it easier for us to help you.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
SELECT COUNT(CallType) AS call_count
FROM tblLog
WHERE CallType = 'Software/May-PS' OR CallType = 'Report Regeneration-PS' OR CallType = 'Training/Info-PS';

I want to show the Count of each individual week in the data base
 
Does the tblLog table have a field the indicates the day? Hopefully this field has a DateTime data type.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
without knowing the table schema, I'll throw out a generic example...

assume col1 is a number, and col2 is a timestamp

select sum(col1), datepart(week,col2)
from myTable
group by datepart(week,col2)

 
I should also mention this is in Access, it may make a difference
 
You might want to verify syntax with the Access forum, then, because there is a difference between the T-SQL used with SQL Server (which is what this forum is for) and the SQL used in Access. If you use the wrong syntax, you won't get the results you want.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
OK, I've gotten this far -

SELECT datepart("ww",DateLogged) as Week_Number,
COUNT(CallType) AS call_count
FROM tblLog
WHERE CallType = 'Software/May-PS' OR CallType = 'Report Regeneration-PS' OR CallType = 'Training/Info-PS'
Group By datepart("ww",DateLogged);


I want to also calculate the % of total calls for the week call_count is
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top