I want to build a query which will have LoanQty, OwedQty and ReturnedQty
OwedQty = LoanQty-ReturnedQty
However, this item can returned separately which means Item1 can loan 4 item.
Then return separately...
How to build this kind of query?
I have 3 different table. 1 is to keep track of the loan requestor which will
produce LoanID, 1 is for borrowing item and 1 is for returning item
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
EMILYTAN
|
7/11/2007 5:54:01 AM |
|
Without knowing a lot more about your table structure this is difficult to
answer. You could try a query that would look something like the following.
SELECT R.LoanID,
, Count(B.LoanID) as ItemsLoaned
, (SELECT Count(C.LoanID) as ItemsReturned
FROM [ItemsReturned] as C
WHERE C.LoanID = R.LoanID) as Returned
, (ItemsLoaned - Nz(Returned)) as StillOut
FROM [Requestor Table] as R INNER JOIN [Borrowed] as B
ON R.LoanId = B.LoanID
GROUP BY R.LoanID
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
"EMILYTAN via AccessMonster.com" <u33296@uwe> wrote in message
news:74ffa15dcdb29@uwe...
>I want to build a query which will have LoanQty, OwedQty and ReturnedQty
>
> OwedQty = LoanQty-ReturnedQty
>
> However, this item can returned separately which means Item1 can loan 4
> item.
> Then return separately...
> How to build this kind of query?
>
> I have 3 different table. 1 is to keep track of the loan requestor which
> will
> produce LoanID, 1 is for borrowing item and 1 is for returning item
>
> --
> Message posted via http://www.accessmonster.com
>
|
|
0
|
|
|
|
Reply
|
John
|
7/11/2007 12:45:14 PM
|
|
My table structure:-
Loan
-loanID, Requestor
-example :- L00001, Mary
LoanBorrow
-lbID, loanID, ItemID, QuantityLoaned, QuantityOwed (Loaned-Returned)
- example :- 001, L00001, M1010-0990, 4, 2
LoanReturn
-lrID, lbID, ItemID, QuantityReturned
-example :- 111, 001, M1010-0990, 1
111, 001, M1010-0990, 1
I can make it work using VBA but it is not instance change as it uses forms
current events...so I want it to be in query...
Thanks...
John Spencer wrote:
>Without knowing a lot more about your table structure this is difficult to
>answer. You could try a query that would look something like the following.
>
>SELECT R.LoanID,
>, Count(B.LoanID) as ItemsLoaned
>, (SELECT Count(C.LoanID) as ItemsReturned
> FROM [ItemsReturned] as C
> WHERE C.LoanID = R.LoanID) as Returned
>, (ItemsLoaned - Nz(Returned)) as StillOut
>FROM [Requestor Table] as R INNER JOIN [Borrowed] as B
>ON R.LoanId = B.LoanID
>GROUP BY R.LoanID
>
>>I want to build a query which will have LoanQty, OwedQty and ReturnedQty
>>
>[quoted text clipped - 8 lines]
>> will
>> produce LoanID, 1 is for borrowing item and 1 is for returning item
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1
|
|
0
|
|
|
|
Reply
|
EMILYTAN
|
7/12/2007 12:28:04 AM
|
|
Assumption:
Loan.LoanID is the Primary key
LoanBorrow.lbID is the Primary key
I would try:
SELECT L.LoanID
, L.Requestor
, B.ItemID
, Sum(B.QuantityLoaned) as Loaned
, Sum(R.QuantityReturned) as Returned
, Sum(B.QuantityLoaned) - Nz(Sum(R.QuantityReturned) ,0) as StillOut
FROM (Loan as L INNER JOIN LoanBorrow as B
ON L.LoanID = B.LoanID) LEFT JOIN LoanReturn as R
ON B.lbId = R.lbID
GROUP BY L.LoanID
, L.Requestor
, B.ItemID
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
"EMILYTAN via AccessMonster.com" <u33296@uwe> wrote in message
news:75095b72d8a02@uwe...
> My table structure:-
>
> Loan
> -loanID, Requestor
> -example :- L00001, Mary
>
> LoanBorrow
> -lbID, loanID, ItemID, QuantityLoaned, QuantityOwed (Loaned-Returned)
> - example :- 001, L00001, M1010-0990, 4, 2
>
> LoanReturn
> -lrID, lbID, ItemID, QuantityReturned
> -example :- 111, 001, M1010-0990, 1
> 111, 001, M1010-0990, 1
>
>
> I can make it work using VBA but it is not instance change as it uses
> forms
> current events...so I want it to be in query...
> Thanks...
> John Spencer wrote:
>>Without knowing a lot more about your table structure this is difficult to
>>answer. You could try a query that would look something like the
>>following.
>>
>>SELECT R.LoanID,
>>, Count(B.LoanID) as ItemsLoaned
>>, (SELECT Count(C.LoanID) as ItemsReturned
>> FROM [ItemsReturned] as C
>> WHERE C.LoanID = R.LoanID) as Returned
>>, (ItemsLoaned - Nz(Returned)) as StillOut
>>FROM [Requestor Table] as R INNER JOIN [Borrowed] as B
>>ON R.LoanId = B.LoanID
>>GROUP BY R.LoanID
>>
>>>I want to build a query which will have LoanQty, OwedQty and ReturnedQty
>>>
>>[quoted text clipped - 8 lines]
>>> will
>>> produce LoanID, 1 is for borrowing item and 1 is for returning item
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1
>
|
|
0
|
|
|
|
Reply
|
John
|
7/12/2007 8:09:19 PM
|
|
|
3 Replies
106 Views
(page loaded in 0.054 seconds)
Similiar Articles: ACH credit files in GP Purchasing - microsoft.public.greatplains ...Loan (re)payments - microsoft.public.greatplains ACH credit files in GP Purchasing ... Hello, Does the Purchasing module within GP support the creation of ACH credit files? SSIS Variables and variables. What is best practise. - microsoft ...Loan (re)payments - microsoft.public.greatplains What is the "best practice" method ... What difference between module and class module? - microsoft ... It is a preferred ... Need "true" or "false" - microsoft.public ...... True - microsoft.public.access I believe, then, that what > > you need in your module ... Answers 29) a person in need of loan may apply for one at a federal reserve bank. ... Calculate a daily rate - microsoft.public.access.queries ...How to Calculate Daily Interest Rates | eHow.com When comparing different loans or ... Calculating Daily Rate for Salary Employees - TASK 2: Manual ... 1 Extract from MODULE ... How to records that the date field = todays date in VBA ...Check for empty date field in Access VBA module... for empty date field in Access VBA ... form which records library loans. If the book has not been returned it should ... about assigning Accounts - microsoft.public.crmHello, I=92m trying to teach myself the Fixed Asset module of GP. I understand how to ... of assigning accounts receivable is to provide collateral in order to obtain a loan. The Exceptional Assistant Core modules - The Loan moduleThe Exceptional Assistant's loan module by CommonGoals Software offers many different financing types for example: term, line of credit, guarantee, equity and leasing. Loan Pipeline Module | TrakPointeJust Where in Our Deal Approval Flow is That Loan Package? Keeping tabs on the status of loan packages is a continuing challenge for banks and credit unions, large ... DownHome Loan Manager - Add-On Modules - DownHome Solutions ...ACH Module - $500. Prepares an electronic file that you can upload to your bank for ACH (Automated Clearing House) processing. Tag some or all of your active loan ... migration of transactions from loan module to m... | SCNWe want to migrate transactions from loan module (SAP banking) to money market (FSCM). The transactions are on borrowing side. Initially we implemented loan module ... EMRC Loans, PML & Collaterals Go Live - Tomorrow Information ...June , 2009 : EMRC Go Live for Loans and PML & Collateral Modules Finally, after several months of testing and requirements customization, the Egyptian Mortgage ... 7/22/2012 7:20:47 AM
|