Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Trying to create an Inventory Aging report through a SQL query, getting an error message

Posted on by Microsoft Employee

CREATE VIEW vw_IVStockAgeing

AS SELECT IV00101.ITEMNMBR AS ITEMNUMBER,

IV00101.ITEMDESC AS ITEMNAME,

IV10200.DATERECD AS DATERECEIVED,

IV10200.QTYRECVD AS QTYRECEIVED,

IV10200.QTYSOLD AS QTYSOLD,

IV00101.ITMCLSCD AS ITEMCLASS,

IV10200.UNITCOST AS UNITCOST,

IV10200.PCHSRCTY AS RECEIPTTYPE,

IV10200.RCPTNMBR AS RECEIPTNO,

IV10200.TRXLOCTN AS LOCATION,

( IV10200.QTYRECVD-IV10200.QTYSOLD ) AS QTYAVAILABLE,

( ( IV10200.QTYRECVD-IV10200.QTYSOLD ) * IV10200.UNITCOST ) AS CURRENTVALUE,

DATEDIFF(day, IV10200.DATERECD, GETDATE()) AS AGEDDAYS,

CASE WHEN DATEDIFF(day, IV10200.DATERECD, GETDATE()) < 0

THEN 'Current'

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 0

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 30

) THEN '0-30 Days' -- 1 month

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 30

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 60

) THEN '31-60 Days' -- 2 months

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 60

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 90

) THEN '61-90 Days' -- 3 months

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 90

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 180

) THEN '91-180 Days' -- 6 months

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 180

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 360

) THEN '181-360 Days' -- 1 year

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 360

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 720

) THEN '> 1 year’ -- 2 years

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 720

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 1440

) THEN '> 2 years -- 3 years

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 1440

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 2880

) THEN '> 3 years’-- 4 years

WHEN ( DATEDIFF(day, IV10200.DATERECD, GETDATE()) > 2880

AND DATEDIFF(day, IV10200.DATERECD, GETDATE()) <= 5760

) THEN '> 4 years-- 5 years

ELSE > 5 years -- Above 5 years

END AS BUCKET

FROM ( IV00101 IV00101

INNER JOIN IV10200 IV10200 ON IV00101.ITEMNMBR = IV10200.ITEMNMBR

)

INNER JOIN IV00102 IV00102 ON IV00101.ITEMNMBR = IV00102.ITEMNMBR

WHERE IV00102.RCRDTYPE = 1

AND IV10200.PCHSRCTY <> 0

 

Getting error below:

Msg 102, Level 15, State 1, Procedure vw_IVStockAgeing, Line 37 [Batch Start Line 0]

Incorrect syntax near '>'.


*This post is locked for comments

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans