web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

SQL view for inventory last sold

(0) ShareShare
ReportReport
Posted on by 110

I'm using this script for inventory last sold. I would like to add a column to this to include “First Receipt Date” to see how many days our inventory has been on hand.

SELECT I.ITEMNMBR Item_Number,
Q.LOCNCODE Site_ID,
I.ITEMDESC Item_Description,
Q.QTYONHND Quantity_on_Hand,
Q.QTYONORD Quantity_on_Order,
U.BASEUOFM U_of_M,
CASE I.ITEMTYPE
WHEN 1 THEN 'Sales Inventory'
WHEN 2 THEN 'Discontinued'
WHEN 3 THEN 'Kit'
WHEN 4 THEN 'Misc Charges'
WHEN 5 THEN 'Services'
WHEN 6 THEN 'Flat Fee'
END Item_Type,
I.CURRCOST Current_Cost,
I.ITMCLSCD Item_Class,
coalesce(S.LastSale,'1/1/1900') Last_Sale_Date,
coalesce(Q.LSRCPTDT,'1/1/1900') Last_Receipt_Date,
coalesce(Q.LSORDVND,'') Last_Vendor

FROM IV00101 I

INNER JOIN
IV00102 Q
ON I.ITEMNMBR = Q.ITEMNMBR
AND RCRDTYPE = 2

LEFT OUTER JOIN
(SELECT ITEMNMBR, MAX(DOCDATE) LastSale, TRXLOCTN
FROM IV30300
WHERE DOCTYPE = 6
GROUP BY ITEMNMBR, TRXLOCTN) S
ON I.ITEMNMBR = S.ITEMNMBR
AND Q.LOCNCODE = S.TRXLOCTN

INNER JOIN
IV40201 U
ON U.UOMSCHDL = I.UOMSCHDL

WHERE Q.QTYONHND <> 0

*This post is locked for comments

I have the same question (0)
  • Frank_Heslin Profile Picture
    895 on at
    RE: SQL view for inventory last sold

    Hi Sunny,

    When I need a SQL view, I ALWAYS start at Victoria Yudin's site.

    https://victoriayudin.com/gp-reports/inventory-sql-views/

  • Tim Wappat Profile Picture
    5,703 on at
    RE: SQL view for inventory last sold

    IV10200 should show you how much of your receipts have been consumed.

    Tim.

  • Verified answer
    SandeepReddyChaganti Profile Picture
    110 on at
    RE: SQL view for inventory last sold

    Thank you Tim. It works

  • SandeepReddyChaganti Profile Picture
    110 on at
    RE: SQL view for inventory last sold

    can you explain in brief

  • SandeepReddyChaganti Profile Picture
    110 on at
    RE: SQL view for inventory last sold

    look's like i'm having wrong results with that join

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans