can someone help me with this memorized report problem??

Mar 17, 2005 3 Replies

i have modified a sales commission report to include tender information by adding a JOIN to the tenderentry table, here is my TablesQueried section from my report:



FROM TransactionEntry WITH(NOLOCK) INNER JOIN [Transaction] WITH(NOLOCK) ON TransactionEntry.TransactionNumber = [Transaction].TransactionNumber LEFT JOIN SalesRep WITH(NOLOCK) ON TransactionEntry.SalesRepID = SalesRep.ID LEFT JOIN Customer WITH (NOLOCK) ON [Transaction].CustomerID = Customer.ID LEFT JOIN Item WITH(NOLOCK) ON TransactionEntry.ItemID = Item.ID LEFT JOIN TenderEntry WITH(NOLOCK) ON TransactionEntry.TransactionNumber TenderEntry.TransactionNumber LEFT JOIN AccountReceivable WITH(NOLOCK) ON TransactionEntry.TransactionNumber = AccountReceivable.TransactionNumber LEFT JOIN c_CommPaid WITH(NOLOCK) ON TransactionEntry.ID = c_CommPaid.TransID



the problem is, now that i have added the JOIN to the TenderEntry table, I am getting duplicate rows in my report. This is because the tenderentry table sometimes has more than one entry for one transactionnumber. For example, if there is a transaction where the customer overtenders in cash and receives change back, there are two entries to the tenderentry table for the same transaction - the only difference in the entries is that the amount on one is the amount the customer tendered with, and the second entry is the change the customer got back.



is there something I can do so that i can still pull data into my report from this table, but eliminate the duplicate rows it is causing?



I thought about adding a WHERE clause to SelCriteria section, something like WHERE TenderEntry.Amount > 0, in order to eliminate one of those records it is pulling into the report. The problem with that is, sometimes there is a return or a void transaction that has a negative amount written to the tenderentry table, and this NEEDS to be pulled into this report.



anyone have another idea??



thank you, kevin


i think i came up w/ a solution for this:

SIGN(TransactionEntry.FullPrice) = SIGN(TenderEntry.Amount)

FullPrice is the field in the TransactionEntry table where the price the item is sold at is written to (positive number if being sold, negative if being returned or transaction is voided). I am just comparing the sign here to the sign of the record or records in the TenderEntry table Amoun field. This way it will only return one record from the table, and it will still return rows where the tender amount is negative.

Just thought I would share in case anyone was interested - it seems to be working as I need it to

kevin

What about sales where you return one item and buy another?

oops that is going to cause problems, thanks for pointing that out. i'm open to suggestions, anyone have a workaround for this?

also, i see now that my original query:

SIGN(TransactionEntry.FullPrice) = SIGN(TenderEntry.Amount)

won't work because the FullPrice is always a positive amount regardless of whether the transaction is a sale, return or void. I would have to use something like the Commission field or the SalesTax field because their signs do change depending on the transaction type.

but it appears I still am going to have a problem with this, and I would appreciate if someone can help me out w/ this

thanks, kevin

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required