PC Review


Reply
Thread Tools Rate Thread

Audrey1980 - Group by

 
 
Audrey1980
Guest
Posts: n/a
 
      15th Apr 2009
Hi

I have the following query where I am getting store + input margin.
The problem is: it is printing out input margin per PG. I want to get an
average across all PGs for the branch (and year and week). I thought if I
just grouped by PG that would work but alas no. I've tried doing an average
of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.

Any other ideas?
Many thanks

PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
SELECT dbo_Despatch_data_branch_summary.Branch,
(([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
FROM dbo_Despatch_data_branch_summary
WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
GROUP BY dbo_Despatch_data_branch_summary.Branch,
dbo_Despatch_data_branch_summary.Extd_WCEV,
dbo_Despatch_data_branch_summary.Extd_REV,
dbo_Despatch_data_branch_summary.PG;

 
Reply With Quote
 
 
 
 
Ken Sheridan
Guest
Posts: n/a
 
      15th Apr 2009
It looks to me like you need to group by Branch and Average the computed
values. Also the declared [Forms]![Main Menu]![Store] Text parameter is not
in fact used, so can be deleted, and I'd imagine the year and week parameters
are in fact integers, not text. So try:

PARAMETERS [Forms]![Main Menu]![Year] SHORT,
[Forms]![Main Menu]![Week] SHORT;
SELECT Branch,
AVG((([Extd_REV]-[Extd_WCEV])/[Extd_REV])) AS [Input Margin]
FROM dbo_Despatch_data_branch_summary
WHERE [Year] =[Forms]![Main Menu]![Year]
AND [Week] = [Forms]![Main Menu]![Week]
GROUP BY Branch;

That should give you the results for one week. To get the results for the
whole year restrict it by the year only:

PARAMETERS [Forms]![Main Menu]![Year] SHORT;
SELECT Branch,
AVG((([Extd_REV]-[Extd_WCEV])/[Extd_REV])) AS [Input Margin]
FROM dbo_Despatch_data_branch_summary
WHERE [Year] =[Forms]![Main Menu]![Year]
GROUP BY Branch;

Ken Sheridan
Stafford, England

"Audrey1980" wrote:

> Hi
>
> I have the following query where I am getting store + input margin.
> The problem is: it is printing out input margin per PG. I want to get an
> average across all PGs for the branch (and year and week). I thought if I
> just grouped by PG that would work but alas no. I've tried doing an average
> of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.
>
> Any other ideas?
> Many thanks
>
> PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> SELECT dbo_Despatch_data_branch_summary.Branch,
> (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> FROM dbo_Despatch_data_branch_summary
> WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> GROUP BY dbo_Despatch_data_branch_summary.Branch,
> dbo_Despatch_data_branch_summary.Extd_WCEV,
> dbo_Despatch_data_branch_summary.Extd_REV,
> dbo_Despatch_data_branch_summary.PG;
>


 
Reply With Quote
 
KARL DEWEY
Guest
Posts: n/a
 
      15th Apr 2009
Try this --
PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
SELECT dbo_Despatch_data_branch_summary.Branch,
(([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
FROM dbo_Despatch_data_branch_summary
WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
GROUP BY dbo_Despatch_data_branch_summary.Branch;


"Audrey1980" wrote:

> Hi
>
> I have the following query where I am getting store + input margin.
> The problem is: it is printing out input margin per PG. I want to get an
> average across all PGs for the branch (and year and week). I thought if I
> just grouped by PG that would work but alas no. I've tried doing an average
> of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.
>
> Any other ideas?
> Many thanks
>
> PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> SELECT dbo_Despatch_data_branch_summary.Branch,
> (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> FROM dbo_Despatch_data_branch_summary
> WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> GROUP BY dbo_Despatch_data_branch_summary.Branch,
> dbo_Despatch_data_branch_summary.Extd_WCEV,
> dbo_Despatch_data_branch_summary.Extd_REV,
> dbo_Despatch_data_branch_summary.PG;
>

 
Reply With Quote
 
Audrey1980
Guest
Posts: n/a
 
      16th Apr 2009
Karl,
THanks but what I got was
"The expression is typed incorrectly or is too complex to be evaluated. Try
simplifying by assigning parts of the expression to variables"

?
Thanks.

"KARL DEWEY" wrote:

> Try this --
> PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> SELECT dbo_Despatch_data_branch_summary.Branch,
> (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> FROM dbo_Despatch_data_branch_summary
> WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> GROUP BY dbo_Despatch_data_branch_summary.Branch;
>
>
> "Audrey1980" wrote:
>
> > Hi
> >
> > I have the following query where I am getting store + input margin.
> > The problem is: it is printing out input margin per PG. I want to get an
> > average across all PGs for the branch (and year and week). I thought if I
> > just grouped by PG that would work but alas no. I've tried doing an average
> > of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.
> >
> > Any other ideas?
> > Many thanks
> >
> > PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> > Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> > SELECT dbo_Despatch_data_branch_summary.Branch,
> > (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> > FROM dbo_Despatch_data_branch_summary
> > WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> > AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> > GROUP BY dbo_Despatch_data_branch_summary.Branch,
> > dbo_Despatch_data_branch_summary.Extd_WCEV,
> > dbo_Despatch_data_branch_summary.Extd_REV,
> > dbo_Despatch_data_branch_summary.PG;
> >

 
Reply With Quote
 
Audrey1980
Guest
Posts: n/a
 
      16th Apr 2009
Karl

Sorry this did work (once I included the 2 columns in the expression) but I
got the result for each product! 64000 rows. I only want one for the store.

Here's what I have now. I need to average out the input margin for the
store. 1 row only required..

PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
SELECT dbo_Despatch_data_branch_summary.Branch,
(([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
FROM dbo_Despatch_data_branch_summary
WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
GROUP BY dbo_Despatch_data_branch_summary.Branch,
dbo_Despatch_data_branch_summary.Extd_WCEV,
dbo_Despatch_data_branch_summary.Extd_REV;




"KARL DEWEY" wrote:

> Try this --
> PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> SELECT dbo_Despatch_data_branch_summary.Branch,
> (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> FROM dbo_Despatch_data_branch_summary
> WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> GROUP BY dbo_Despatch_data_branch_summary.Branch;
>
>
> "Audrey1980" wrote:
>
> > Hi
> >
> > I have the following query where I am getting store + input margin.
> > The problem is: it is printing out input margin per PG. I want to get an
> > average across all PGs for the branch (and year and week). I thought if I
> > just grouped by PG that would work but alas no. I've tried doing an average
> > of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.
> >
> > Any other ideas?
> > Many thanks
> >
> > PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> > Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> > SELECT dbo_Despatch_data_branch_summary.Branch,
> > (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> > FROM dbo_Despatch_data_branch_summary
> > WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> > AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> > GROUP BY dbo_Despatch_data_branch_summary.Branch,
> > dbo_Despatch_data_branch_summary.Extd_WCEV,
> > dbo_Despatch_data_branch_summary.Extd_REV,
> > dbo_Despatch_data_branch_summary.PG;
> >

 
Reply With Quote
 
KARL DEWEY
Guest
Posts: n/a
 
      16th Apr 2009
You have to remove Extd_WCEV and Extd_REV from the Group By statement. Even
though you do not have them in your select statement but in the group by your
query subdivides the results into three levels - Branch, Extd_WCEV, and
Extd_REV.


"Audrey1980" wrote:

> Karl
>
> Sorry this did work (once I included the 2 columns in the expression) but I
> got the result for each product! 64000 rows. I only want one for the store.
>
> Here's what I have now. I need to average out the input margin for the
> store. 1 row only required..
>
> PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> SELECT dbo_Despatch_data_branch_summary.Branch,
> (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> FROM dbo_Despatch_data_branch_summary
> WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> GROUP BY dbo_Despatch_data_branch_summary.Branch,
> dbo_Despatch_data_branch_summary.Extd_WCEV,
> dbo_Despatch_data_branch_summary.Extd_REV;
>
>
>
>
> "KARL DEWEY" wrote:
>
> > Try this --
> > PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> > Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> > SELECT dbo_Despatch_data_branch_summary.Branch,
> > (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> > FROM dbo_Despatch_data_branch_summary
> > WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> > AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> > GROUP BY dbo_Despatch_data_branch_summary.Branch;
> >
> >
> > "Audrey1980" wrote:
> >
> > > Hi
> > >
> > > I have the following query where I am getting store + input margin.
> > > The problem is: it is printing out input margin per PG. I want to get an
> > > average across all PGs for the branch (and year and week). I thought if I
> > > just grouped by PG that would work but alas no. I've tried doing an average
> > > of (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) but it doesnt like this.
> > >
> > > Any other ideas?
> > > Many thanks
> > >
> > > PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
> > > Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
> > > SELECT dbo_Despatch_data_branch_summary.Branch,
> > > (([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin]
> > > FROM dbo_Despatch_data_branch_summary
> > > WHERE (((dbo_Despatch_data_branch_summary.Year)=[Forms]![Main Menu]![Year])
> > > AND ((dbo_Despatch_data_branch_summary.Week)=[Forms]![Main Menu]![Week]))
> > > GROUP BY dbo_Despatch_data_branch_summary.Branch,
> > > dbo_Despatch_data_branch_summary.Extd_WCEV,
> > > dbo_Despatch_data_branch_summary.Extd_REV,
> > > dbo_Despatch_data_branch_summary.PG;
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Never will be a Microsoft NNTP Windows 7 group; ever. (was: There is no Win7 group What is the most active group for Win7?) N. Miller Windows XP General 6 21st Apr 2011 01:36 PM
Never will be a Midrosoft NNTP Windows 7 group; ever. (was: There is no Win7 group What is the most active group for Win7?) N. Miller Windows XP General 0 17th Apr 2011 08:47 PM
enabled locked property option group and buttons in group confusion brian Microsoft Access Forms 1 3rd Jul 2007 02:00 AM
Active Directory Group Policies not showing in Group Policy editor Chupacabra Microsoft Windows 2000 Group Policy 2 9th Dec 2004 05:18 PM
Assigning Software to a Specific Group by Using a Group Policy doesn't work Jason Microsoft Windows 2000 Group Policy 9 10th Jul 2003 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:38 PM.