A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Dividing sum by 2



 
 
Thread Tools Display Modes
  #1  
Old October 4th, 2006, 02:25 PM posted to microsoft.public.access.queries
JeffH13
external usenet poster
 
Posts: 9
Default Dividing sum by 2

I have a query that accumulate the sum of material. The query has Material,
Qty(sum), Assemble (Check Box) which is set to 'NO' and Material Type.

If the Material Type is '5' then the Qty(sum) needs to be divided by 2. If
the Material Type is any other value it would be Qty(sum).

Any Idea's.......
  #2  
Old October 4th, 2006, 02:41 PM posted to microsoft.public.access.queries
geebee
external usenet poster
 
Posts: 111
Default Dividing sum by 2

hi,

Try this...

SELECT tbl_name.material, IIf([material_type]='2',Qty(Sum), Qty(Sum)/2) AS
new_column_name, tbl_name.assemble
FROM tbl_name
GROUP BY tbl_name.material, tbl_name.assemble;

Hope this helps,
geebee


"JeffH13" wrote:

I have a query that accumulate the sum of material. The query has Material,
Qty(sum), Assemble (Check Box) which is set to 'NO' and Material Type.

If the Material Type is '5' then the Qty(sum) needs to be divided by 2. If
the Material Type is any other value it would be Qty(sum).

Any Idea's.......

  #3  
Old October 4th, 2006, 05:48 PM posted to microsoft.public.access.queries
JeffH13
external usenet poster
 
Posts: 9
Default Dividing sum by 2

This is what I'm starting with....
-----
SELECT DISTINCTROW [tbl Material].Type, [Material Estimate CV].Material,
Sum([Material Estimate CV].Qty) AS SumOfQty, Production.[Ass Date]

FROM [tbl Material] INNER JOIN (Production INNER JOIN [Material Estimate CV]
ON Production.[Job #] = [Material Estimate CV].[Job Number]) ON [tbl
Material].Name = [Material Estimate CV].Material

GROUP BY [tbl Material].Type, [Material Estimate CV].Material,
Production.[Ass Date], Production.Ass

HAVING (((Production.[Ass Date]) Between CDate(Date()-Day(Date())+1) And
DateSerial(Year(Date()),Month(Date())+1,0)) AND ((Production.Ass)=Yes));
-----

I having problems understand how the IIF statement should be written...
........
SELECT DISTINCTROW [tbl Material].Type, IIf([tbl
Material].Type='5',([Material Estimate CV].Material, Sum([Material Estimate
CV].Qty) AS SumOfQty, Production.[Ass Date])/2,([Material Estimate
CV].Material, Sum([Material Estimate CV].Qty) AS SumOfQty, Production.[Ass
Date])
.........
This doesn't work....
I'm I totally off base.....

Thanks for you help
"geebee" wrote:

hi,

Try this...

SELECT tbl_name.material, IIf([material_type]='2',Qty(Sum), Qty(Sum)/2) AS
new_column_name, tbl_name.assemble
FROM tbl_name
GROUP BY tbl_name.material, tbl_name.assemble;

Hope this helps,
geebee


"JeffH13" wrote:

I have a query that accumulate the sum of material. The query has Material,
Qty(sum), Assemble (Check Box) which is set to 'NO' and Material Type.

If the Material Type is '5' then the Qty(sum) needs to be divided by 2. If
the Material Type is any other value it would be Qty(sum).

Any Idea's.......

  #4  
Old October 4th, 2006, 06:09 PM posted to microsoft.public.access.queries
geebee
external usenet poster
 
Posts: 111
Default Dividing sum by 2

hi,

The syntax for your IIf column in the query would be...

IIf([tbl
Material].Type='5',(Sum([Material Estimate CV].Qty)/2, Sum([Material
Estimate CV]))
AS SumOfQty

I noticed you are taking from 2 tables? If so, I see no join clause in
there joining the 2 tables. If you are using a nested query, then this
should work.

Hope this helps,
geebee


"JeffH13" wrote:

This is what I'm starting with....
-----
SELECT DISTINCTROW [tbl Material].Type, [Material Estimate CV].Material,
Sum([Material Estimate CV].Qty) AS SumOfQty, Production.[Ass Date]

FROM [tbl Material] INNER JOIN (Production INNER JOIN [Material Estimate CV]
ON Production.[Job #] = [Material Estimate CV].[Job Number]) ON [tbl
Material].Name = [Material Estimate CV].Material

GROUP BY [tbl Material].Type, [Material Estimate CV].Material,
Production.[Ass Date], Production.Ass

HAVING (((Production.[Ass Date]) Between CDate(Date()-Day(Date())+1) And
DateSerial(Year(Date()),Month(Date())+1,0)) AND ((Production.Ass)=Yes));
-----

I having problems understand how the IIF statement should be written...
.......
SELECT DISTINCTROW [tbl Material].Type, IIf([tbl
Material].Type='5',([Material Estimate CV].Material, Sum([Material Estimate
CV].Qty) AS SumOfQty, Production.[Ass Date])/2,([Material Estimate
CV].Material, Sum([Material Estimate CV].Qty) AS SumOfQty, Production.[Ass
Date])
........
This doesn't work....
I'm I totally off base.....

Thanks for you help
"geebee" wrote:

hi,

Try this...

SELECT tbl_name.material, IIf([material_type]='2',Qty(Sum), Qty(Sum)/2) AS
new_column_name, tbl_name.assemble
FROM tbl_name
GROUP BY tbl_name.material, tbl_name.assemble;

Hope this helps,
geebee


"JeffH13" wrote:

I have a query that accumulate the sum of material. The query has Material,
Qty(sum), Assemble (Check Box) which is set to 'NO' and Material Type.

If the Material Type is '5' then the Qty(sum) needs to be divided by 2. If
the Material Type is any other value it would be Qty(sum).

Any Idea's.......

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.