Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics RMS (Archived)

Need to run this query please help..

(0) ShareShare
ReportReport
Posted on by

 We are a new store that started up a while back,  i need to run this query to find items that are currently not on order and have been sold since i opened and have less then 1 in stock.  What happened was the vendor i have for my retail goods sent me only a few of this and a few of that  for some items.  I want to possibly re-order those items but since i never set reorder points until after we were running i cant seem to get a PO generated with the items i might have sold before.  I've tried under reports--items--quantity..  but i seem to not be able to parse out those items that might currently be on order. 

 

All items sold since XXX DATE
where supplier = FOO

and onhand =< 1
and currently on order is 0

*This post is locked for comments

  • TimB Profile Picture
    1,175 on at
    Re: Need to run this query please help..

    Try this code. Just change the suppliercode and solddate variables to the values you need them. Regards, Tim


    declare @SupplierCode nvarchar(50)
    declare @SoldDate datetime

    set @SupplierCode = 'Walmart'
    set @SoldDate = '5/1/2010'

    select i.* from item i
    left join (select itemid,sum(quantityordered - quantityreceivedtodate) as onorder from purchaseorderentry where purchaseorderid in (select id from purchaseorder where potype = 0 and status in (0,1)) group by itemid) o on i.id = o.itemid

    left join (select te.itemid from transactionentry te left join [transaction] t on te.transactionnumber = t.transactionnumber where t.time > @SoldDate group by te.itemid) s on i.id = s.itemid

    where i.supplierid = (select id from supplier where code = @SupplierCode)

    and i.quantity < 1
    and isnull(o.onorder,0) = 0
    and isnull(s.itemid,0) > 0

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,217 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,978 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans