PC Review


Reply
Thread Tools Rate Thread

Dsum Problem with date criteria

 
 
naveen prasad
Guest
Posts: n/a
 
      7th Jun 2010
Hi all,
Kindly solve my problem.

I have 2 tables stock_received , stock_utilized.

stock_received fields -- date,3pcs,4pcs,boxes.

stock_utilized fields -- date,3pcs,4pcs,boxes.

I have successfully made a query to get the the current stock in hand as

select sum(3pcs)- dsum("3pcs","stock_utilized"),
sum(4pcs)-dsum("4pcs","stock_utilized"),sum(boxes)-dsum("boxes","stock_utilized") from stock_received ;

Here i have a complex problem, I cant make query with date criteria.

for example 01/05/2010 to 30/05/2010

I want to get how much stock received in that dates and how much was
utilized and how much is balance.

kindly help me how should i write query.


 
Reply With Quote
 
 
 
 
vanderghast
Guest
Posts: n/a
 
      7th Jun 2010
It would be easier and faster (at execution time) to use a single table
(with negative quantity for utilized items).

SELECT [3pcs] AS qty, [date] AS dateStamp FROM stock_received
UNION ALL
SELECT -[3pcs], [date] FROM stock_utilized


as a saved query will do that 'table' (without indexes, though), assume it
is called q1, then:

SELECT SUM(iif(qty>0, qty, 0)) AS receivedQty,
SUM(iif(qty<0, -qty, 0)) AS utilizedQty,
SUM(qty) AS brutQty
FROM q1
WHERE dateStamp BETWEEN #01/05/2010# AND #30/05/2010#

should to for the given date interval.


Vanderghast, Access MVP



"naveen prasad" <(E-Mail Removed)> wrote in message
news:C08F0320-30A9-43FC-80C3-(E-Mail Removed)...
> Hi all,
> Kindly solve my problem.
>
> I have 2 tables stock_received , stock_utilized.
>
> stock_received fields -- date,3pcs,4pcs,boxes.
>
> stock_utilized fields -- date,3pcs,4pcs,boxes.
>
> I have successfully made a query to get the the current stock in hand as
>
> select sum(3pcs)- dsum("3pcs","stock_utilized"),
> sum(4pcs)-dsum("4pcs","stock_utilized"),sum(boxes)-dsum("boxes","stock_utilized")
> from stock_received ;
>
> Here i have a complex problem, I cant make query with date criteria.
>
> for example 01/05/2010 to 30/05/2010
>
> I want to get how much stock received in that dates and how much was
> utilized and how much is balance.
>
> kindly help me how should i write query.
>
>


 
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
DSum With Multiple Criteria and Date Value Okestra007 Microsoft Access Queries 0 27th Sep 2011 05:41 PM
DSUM Date Criteria Rebeca Microsoft Access Queries 3 22nd Mar 2010 03:19 PM
DSum and date as criteria Andreas Microsoft Access 3 29th Dec 2009 10:55 PM
DSUM Date Criteria =?Utf-8?B?anNjY29ycHM=?= Microsoft Access Reports 2 3rd Feb 2006 12:58 PM
dsum with date criteria =?Utf-8?B?TWljaGVsIGZyb20gQmVsZ2l1bQ==?= Microsoft Excel Worksheet Functions 2 24th Mar 2005 05:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 PM.