Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

Help on IF Expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shirley - 08 Nov 2007 15:47 GMT
Hi,

I have a purchase order table, which shows duplicate purchase orders with a
status of Active (A), Closed (C) and Cancelled (X).  See example below

PO No.        Status            Amount
CIP23          A                  4,500
CIP23          C                  1,000
CIP23          X                  2,000

How do I create an expression that sums the amount of the purchase order no.
CIP23 with a status of A or C?   In the example above, the result for CIP23
would be 5,500 under this criteria.

Thanks.  
Signature

Shirley

John Spencer - 08 Nov 2007 16:22 GMT
SELECT [PO No.]
, Sum(amount) as TheAmount
FROM YourTable
WHERE Status in ("A","C")
GROUP BY [Po No.]

Another way if you want to show all PO numbers even if they only have a
Status of X

SELECT [PO No.]
, Sum(IIF [Status] in ("A","C"),Amount,Null) as TheAmount
FROM YourTable
GROUP BY [Po No.]

If you can only work with the Design View (query grid) then post back for
instructions on building this query that way.

Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Hi,
>
[quoted text clipped - 14 lines]
>
> Thanks.
Jerry Whittle - 08 Nov 2007 16:27 GMT
SELECT [PO No.], Sum(Amount) AS SumOfAmt
FROM YourTable
WHERE Status In ("A","C")
GROUP BY [PO No.] ;
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> Hi,
>
[quoted text clipped - 11 lines]
>
> Thanks.  
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.