Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

inventory movement query

(0) ShareShare
ReportReport
Posted on by 69

I am trying to develop a query to tell me the last time an inventory item was acted upon in the system, then also tell me its total cost and total quantity on hand.  I want to use the intran and the itemsite tables, and use the field intvid as the key field.

So far, this query works for me and returns good results:

select [Inventory ID], [Total Cost], [Total Quantity]

from

(

 select itemsite.invtid as "Inventory ID",
  sum (itemsite.TotCost) as "Total Cost",
        sum (itemsite.QtyOnHand) as "Total Quantity"
      
      
       from ItemSite
       group by itemsite.invtid
       
  )
 
 itemsite

 

AND this query works for me

 

select [Inventory ID], [Last Touched]

from

(
select intran.invtid as "Inventory ID", MAX (intran.Perpost) as "Last Touched"

from Intran where

  intran.Rlsed = 1
  and intran.S4Future05 = 0
 
  group by intran.invtid
 
 )
 
  intran

 

But, I need to join them into one query to product a list of 4 fields and I can not get that to work.  I am wondering the proper format.  Any help would be appreciated

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: inventory movement query

    If you want LEFT OUTER JOIN

    select isite.[Inventory ID], isite.[Total Cost], isite.[Total Quantity], itran.[Last Touched]
    from
    (
    select itemsite.invtid as "Inventory ID",
    sum (itemsite.TotCost) as "Total Cost",
    sum (itemsite.QtyOnHand) as "Total Quantity"
    from ItemSite
    group by itemsite.invtid
    ) AS isite
    LEFT OUTER JOIN
    (
    select intran.invtid as "Inventory ID", MAX (intran.Perpost) as "Last Touched"
    from Intran where
    intran.Rlsed = 1
    and intran.S4Future05 = 0
    group by intran.invtid
    ) AS itran
    ON isite.[Inventory ID] = itran.[Inventory ID]

    If you want INNER JOIN,

    select isite.[Inventory ID], isite.[Total Cost], isite.[Total Quantity], itran.[Last Touched]
    from
    (
    select itemsite.invtid as "Inventory ID",
    sum (itemsite.TotCost) as "Total Cost",
    sum (itemsite.QtyOnHand) as "Total Quantity"
    from ItemSite
    group by itemsite.invtid
    ) AS isite,
    (
    select intran.invtid as "Inventory ID", MAX (intran.Perpost) as "Last Touched"
    from Intran where
    intran.Rlsed = 1
    and intran.S4Future05 = 0
    group by intran.invtid
    ) AS itran
    WHERE isite.[Inventory ID] = itran.[Inventory ID]

  • Community Member Profile Picture
    on at
    RE: inventory movement query

    select ITM.*, [Last Touched] from

    (select [Inventory ID], [Total Cost], [Total Quantity]

    from

    (

    select itemsite.invtid as "Inventory ID",

     sum (itemsite.TotCost) as "Total Cost",

           sum (itemsite.QtyOnHand) as "Total Quantity"

          from ItemSite

          group by itemsite.invtid

     )

    itemsite) ITM

    JOIN

    (select [Inventory ID], [Last Touched]

    from

    (

    select intran.invtid as "Inventory ID", MAX (intran.Perpost) as "Last Touched"

    from Intran where

     intran.Rlsed = 1

     and intran.S4Future05 = 0

     group by intran.invtid

    )   intran) INT

     on ITM.[Inventory ID] = INT.[Inventory ID]

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

#1
Community Member Profile Picture

Community Member 136

#2
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 102 Super User 2025 Season 1

#3
REUser Profile Picture

REUser 8

Featured topics

Product updates

Dynamics 365 release plans