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  

calculated field - difficult



 
 
Thread Tools Display Modes
  #11  
Old March 8th, 2010, 01:58 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default calculated field - difficult

On Sun, 7 Mar 2010 17:20:01 -0800, clalc
wrote:

Sorry I used another name for QTY that's why I was getting this message. I
fixed it now, but I'm still not getting the right numbers.


If you would like help solving the problem, please post the current SQL of the
query, and an example of the data in your table, the wrong answer you're
getting, and the answer you desire to get.
--

John W. Vinson [MVP]
  #12  
Old March 8th, 2010, 01:19 PM posted to microsoft.public.access.queries
clalc
external usenet poster
 
Posts: 16
Default calculated field - difficult

Here are the tables:
Table Demand
Item Qty Date
aaa 10 03-mar-2010
aaa 7 05-mar-2010
aaa 5 12-mar-2010
ccc 8 06-mar-2010
ccc 12 09-mar-2010

Table Stock
Item Qty
aaa 12
bbb 9
ccc 6

the result should be table Net Demand
Item Qty Date (how to get column Qty)
aaa 0 03-mar-2010 (12-10, left 2)
aaa 5 05-mar-20 (7-2, left 0)
aaa 5 12-mar-2010 (5-0, left 0)
ccc 2 06-mar-2010 (8-6, left 0)
ccc 12 09-mar-2010 (12-0, left 0)

Here is SQL which does not give the results as above:
SELECT Demand.Item, Demand.Date, (SELECT IIF((Stock.[Qty] -
Sum([XX].[QTY])) 0,0, (Stock.[Qty] - Sum([XX].[QTY]))*-1) FROM
Demand AS [XX] WHERE [XX].Date = Demand.Date AND [XX].Item
= Demand.Item) AS ToOrder
FROM Demand LEFT JOIN Stock ON Demand.Item = Stock.Item
ORDER BY Demand.Item, Demand.FillDate;
Would you have any suggestions ?


"John W. Vinson" wrote:

On Sun, 7 Mar 2010 17:20:01 -0800, clalc
wrote:

Sorry I used another name for QTY that's why I was getting this message. I
fixed it now, but I'm still not getting the right numbers.


If you would like help solving the problem, please post the current SQL of the
query, and an example of the data in your table, the wrong answer you're
getting, and the answer you desire to get.
--

John W. Vinson [MVP]
.

 




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 12:06 PM.


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