Problem filtering by resource in virtual table parameters

Common questions about 1C:Query language, Query builder tool and Data composition schema

#1
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company: TLG Integration

Hello!
I need to get a stock filtered by warehouse.
Here is my query, I've optimized it to work faster by placing a condition into virtual table parameters:

Code
SEL ECT 
    StockSliceLast.Quantity, 
    StockSliceLast.Inventory, 
    StockSliceLast.Cell 
FR OM 
    InformationRegister.Stock.SliceLast(&Period, Contractor = &Contractor) AS StockSliceLast

The problem is that it returns all inventory which ever have been assigned to this contractor while I need only ones which are in stock by the date in Period.

 
#2
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Don't use virtual tables

Code
SELECT
    ...
FR OM 
    InformationRegister.Stock
WH ERE
    BEGINOFPERIOD(Period, DAY) = &Period
    AND Contractor = &Contractor

 
#3
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company: TLG Integration

But I need last ones only

 
#4
People who like this:1Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

When you apply condition inside the virtual table of register it first filters by condition and then gets a slice, so you need to place your condition after you get a slice in WHERE clause:

Code
SELECT 
    StockSliceLast.Quantity, 
    StockSliceLast.Inventory, 
    StockSliceLast.Cell 
FROM 
    InformationRegister.Stock.SliceLast(&Period, ) AS StockSliceLast 
WHERE
    StockSliceLast.Contractor = &Contractor

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.