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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

percentage query 1

Status
Not open for further replies.

dinster

Programmer
Apr 12, 2007
54
GB
Hi all,

I have query which shows number of records for each day. How do i go about changing this so that it can give me the percentage of each.

This what i got so far...
Code:
SELECT Sum(IIf(Format([DateAdded],"dddd")="Monday",1,0)) AS Monday, Sum(IIf(Format([DateAdded],"dddd")="Tuesday",1,0)) AS Tuesday, Sum(IIf(Format([DateAdded],"dddd")="Wednesday",1,0)) AS Wednesday, Sum(IIf(Format([DateAdded],"dddd")="Thursday",1,0)) AS Thursday, Sum(IIf(Format([DateAdded],"dddd")="Friday",1,0)) AS Friday, Sum(IIf(Format([DateAdded],"dddd")="Saturday",1,0)) AS Saturday, Sum(IIf(Format([DateAdded],"dddd")="Sunday",1,0)) AS Sunday
FROM Sheet4;


so basically i want the tatal number of records then divide each day by that ....and times by 100. Not sure how to go bout this


many thanx
 
oh i sussed it out...eventually :)
Code:
SELECT (Sum(IIf(Format([DateAdded],"dddd")="Monday",1,0))/DCount("[ID]","sheet4"))*100 AS Monday, (Sum(IIf(Format([DateAdded],"dddd")="Tuesday",1,0))/DCount("[ID]","sheet4"))*100 AS Tuesday, (Sum(IIf(Format([DateAdded],"dddd")="Wednesday",1,0))/DCount("[ID]","sheet4"))*100 AS Wednesday, (Sum(IIf(Format([DateAdded],"dddd")="Thursday",1,0))/DCount("[ID]","sheet4"))*100 AS Thursday, (Sum(IIf(Format([DateAdded],"dddd")="Friday",1,0))/DCount("[ID]","sheet4"))*100 AS Friday, (Sum(IIf(Format([DateAdded],"dddd")="Saturday",1,0))/DCount("[ID]","sheet4"))*100 AS Saturday, (Sum(IIf(Format([DateAdded],"dddd")="Sunday",1,0))/DCount("[ID]","sheet4"))*100 AS Sunday
FROM Sheet4;
 
And this ?
Code:
SELECT 100*Sum(IIf(Format([DateAdded],"dddd")="Monday",1,0))/Count(*) AS Monday, ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top