Query for item warehouses stock in a row

hi all,
How to retreive item warehouse stock in a row using query ?
SELECT T0.ItemCode, T1.ItemName, T2.ItmsGrpNam,
(Select WhsCode from OITW Where
WhsCode=T0.WhsCode and ItemCode=T0.ItemCode) as 'Wh',
(Select OnHand From OITW Where
Whscode = T0.WhsCode and Itemcode=T0.ItemCode) as 'Whstck'
FROM OITW T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod
WHERE T0.ItemCode NOT IN 'a-item'AND
T2.ItmsGrpNam LIKE '%%test%%'
and T0.Onhand > 0
ORDER BY T0.ItemCode
Anyone correct query so that it will retrieve item warehouse stock in a single row.
Thanks
Jeyakanthan

I have tested your query, the result is just like you wish. The code can be simplified to:
SELECT T0.ItemCode, T1.ItemName, T2.ItmsGrpNam, T0.WhsCode as 'Wh',T0.OnHand as 'Whstck'
FROM DBO.OITW T0 
INNER JOIN DBO.OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN DBO.OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod
WHERE T0.ItemCode NOT IN ('a-item') AND T2.ItmsGrpNam LIKE '%[%test%]%'
and T0.Onhand > 0
ORDER BY T0.ItemCode, T0.WhsCode
If you want each item has only one row and warehouse on hand column-wised, you have to use as much as SELECT for each column in according to your number of warehouses. It would be look like this one:
SELECT T0.ItemCode, T0.ItemName, T1.ItmsGrpNam,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs1') AS 'Whs1 On Hand' ,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs2') AS 'Whs2 On Hand' ,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs3') AS 'Whs3 On Hand'
FROM DBO.OITM T0 
INNER JOIN DBO.OITB T1 ON T1.ItmsGrpCod = T0.ItmsGrpCod
WHERE T0.ItemCode NOT IN ('a-item') AND T1.ItmsGrpNam LIKE '%[%test%]%'
and T0.Onhand > 0
ORDER BY T0.ItemCode
Thanks,
Gordon

Similar Messages

  • Re:Query for items having Stock for a particular warehouse ..!!!

    Dear SAP Members,
    I need a query to display a list of items having stock by considering all the marketing documents,goods receipt,BOM,Production Order,etc.
    I have written query like this:
    SELECT T0.[ItemCode], T0.[ItemName], T1.[ItmsGrpNam],T0.[OnHand],
    T0.[IsCommited], T0.[OnOrder] FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod
    WHERE T1.[ItmsGrpNam] ='[%0]' or  T0.[DfltWH] ='[%1]'
    The issue is
    The InStock shows the total by calculating all warehouses stock but i need the total for the default warehouse.
    Plz suggest or modify my query if i have missed out any fields.
    With Regards,
    Revathy

    Hi Revathy,
    Try this
    SELECT T0.[ItemCode], T0.[ItemName], T1.[ItmsGrpNam],T2.[OnHand],
    T0.[IsCommited], T0.[OnOrder] FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod
    inner join OITW T2 on T2.ItemCode =T0.ItemCode 
    WHERE T1.[ItmsGrpNam] ='[%0]' and T0.[DfltWH] = T2.WhsCode
    Or
    SELECT T0.[ItemCode], T0.[ItemName], T1.[ItmsGrpNam],T2.[OnHand],
    T0.[IsCommited], T0.[OnOrder] FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod
    inner join OITW T2 on T2.ItemCode =T0.ItemCode 
    WHERE T1.[ItmsGrpNam] ='[%0]' and T2.WhsCode ='[%1]'
    Regards,
    Bala

  • How to create sql query for item master with operator LIKE with variables?

    hi all,
    How to create sql query for item master with
    operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
    Jeyakanthan

    Hi Jeyakanthan,
    here is an example (put the like statement into the where field)
    SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
    The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
    Regards Steffen

  • Query for item master data

    hi all,
    i want to create a query for items in the item master data that shows the changed field, the old value, the new value, user name and the date it was changed .
    can anyone help please.
    ciao

    thanks for the reply
    my clients internal auditors require that they have Exception Reports in SAP , i.e reports that can show changes made, date and by which user etc...
    1. changes made to item master data
    2. changes made to business partner master data
    3. changes made to invoices, purchase orders etc..
    this reports can be set in query form or xl reporter..
    i tried but couldent find the tables ....
    any sugestion will be appriciated..

  • Re:Query for Item and its first child Itemcode from BOM...!!!

    Dear SAP Members,
    I need a query that contains
    ItemCode,ItemDescription from oitm table and its first child item code,Item Description,Quantity,currency and price from itt1 table.I have taken all the datas but there is no ItemDescription from itt1 table.How to join all these datas.
    Please Give suggestions or query for this issue.
    With Regards,
    Revathy

    Hi try this
    Declare @BOMDetails table(TreeType Nvarchar(MAX),PItem NVARCHAR(Max),PName NVARCHAR(MAX),CItem  NVARCHAR(Max),CName NVARCHAR(MAX),Comment NVARCHAR(MAX),onHand Numeric(18,0),[Committed] Numeric(18,0),FreeStock Numeric(18,0),[Status] NVARCHAR(MAX),Quantity numeric(18,0),Price numeric(18,0),Warehouse nvarchar(MAX),Currency nvarchar(MAX))
    INSERT Into @BOMDetails
    SELECT T1.TreeType ,T0.Father AS [Parent Code], T2.ItemName AS [Parent Description], T0.Code AS [Child Code],
    T1.ItemName AS [Child Description], T0.Comment, cast((T1.OnHand ) as Numeric(18,0)) as [Un-Committed Stock],
    cast(T1.IsCommited as Numeric(18,0)) AS [Committed Stock], cast((T1.OnHand - T1.IsCommited)as Numeric(18,0)) AS [Free Stock], T2.FrgnName AS [Status],T0.Quantity,T0.Price ,T0.Warehouse,T0.Currency
    FROM ITT1 T0 INNER JOIN OITM T1 ON T0.Code = T1.ItemCode
                 INNER JOIN OITM T2 ON T0.Father = T2.ItemCode
    WHERE T0.ChildNum=1
    Union All
    SELECT ' ',T0.Father as [Parent Code], T2.ItemName AS [Parent Description], '', '', '', 0,0,0 , '',0,0,'','' FROM ITT1 T0 INNER JOIN OITM T1
    ON T0.Code = T1.ItemCode INNER JOIN OITM T2 ON T0.Father = T2.ItemCode
    Group By T0.Father,T2.ItemName
    ORDER BY T0.Father, T0.Code
    update @BOMDetails set PItem='' ,PName='' where TreeType='N' or TreeType='P'
    Select PItem as[Parent Code] ,PName as [Parent Description],CItem as [Child Code],CName as [Child Description],Comment,Quantity,Price,Warehouse,Currency   from @BOMDetails
    thanks,
    Neetu

  • Query for Item wise sales report

    Hi Guys,
    Below is the query i have used to run Sales Register.
    But we need Item wise sales register  and those Excise Duty calculations are needed for item wise instead of total document wise. Pls update the query ...
    SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price,
    (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
    (SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ', L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
    FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
    WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
    GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
    ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal

    Hi experts..
    Pls   Update the Query

  • Query for Item wise Sales.......

    *Hi Guys, Below is the query i have used to run Sales Register. But we need Item wise sales register and those Excise Duty calculations are needed for item wise instead of total document wise.
    Pls update the query ...*
    SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price, (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)', (SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ', (SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ', (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ', (SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ', (SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ', (SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ', (SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ', (SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ', (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ', (SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ', L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total' FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14 GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal

    Closing this ...
    Edited by: Parimis on Jun 25, 2010 5:44 PM

  • Notification Query for Item Group

    Dear Experts,
    Please Guide me for a Notification Query for this Scenario :
    I want to put a Notification Query for a  Group i.e. when any user do transactions in any form or any Particular form using items
    of this Group than if the Item Quantity is in Decimal then he can not do that Transaction and Get Error Message.
    Thanks in Advance.
    Atul Chakraborty

    Hi Atul,
    to achieve this you have to write SPTN at the back end
    under databases node select your live database.
    Select programability
    select stored procedure
    select db.sbo.SP_Transactionnotification
    and paste your code into
    ADD YOUR CODE AREA
    If (@object_type = '17') and (@transaction_type in ('A', 'U'))
    BEGIN
         Declare @ItmGrpCode as int
         Declare @Qty as int
         set @ItmGrpcode = (select oitm.itmsgrpcod from oitm inner join rdr1 on oitm.itemcode = rdr1.itemcode inner join ordr on   
            rdr1.docentry = ordr.docentry where  ordr.docentry=@list_of_cols_val_tab_del)
            set @Qty = (select quantity from rdr1 inner join ordr on ordr.docentry = rdr1.docentry where ordr.docentry =
            @list_of_cols_val_tab_del)
         BEGIN
                        if @ItmGrpcode = 10 and @qty = 0
                        Begin
                             set @error = -1
                             set @error_message = 'Invalid Input'
                       End
           End
    END
    Like wise by capturing object type and dml mode you have to write code for every document that you want to check.
    For example I've given code for Sales Order.
    hope this will help you
    Thanking you
    Malhaar'

  • Query for batchwise remaining stock

    Hello
    i create the following query that show remaining quantity in that batch the quer are as,
    SELECT T0.[ItemCode], T0.[Quantity], T0.[WhsCode], T3.[ItmsGrpNam], T1.[DistNumber] FROM OBTQ T0  INNER JOIN OBTN T1 ON T0.AbsEntry = T1.AbsEntry INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod WHERE T0.[WhsCode] ='WH01' ORDER BY T3.[ItmsGrpNam], T0.[ItemCode]
    but i want to more field in that query that it should show purchase price for that batch & remaining quantity
    the qurey should display
    Item code , Remaining Quantity, Warehouse,ItemGrpName,batch Num, Purchase Price

    Hi,
    Try:
    SELECT T0.ItemCode, (T0.Quantity-T0.CommitQty) 'Remaining Qty', T0.WhsCode, T3.ItmsGrpNam, T1.DistNumber,T2.LastPurPrc
    FROM OBTQ T0
    INNER JOIN OBTN T1 ON T0.AbsEntry = T1.AbsEntry
    INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode
    INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
    WHERE T0.WhsCode ='WH01'
    ORDER BY T3.ItmsGrpNam, T0.ItemCode
    Thanks,
    Gordon

  • Crystal Query for Opening / Closing Stock

    Hi Experts,
    i need a query in crystal for Opening and Closing total Stock per date..
    i found this querys and need to join them, but o dont now how...
    thanks for any tips..
    Query 1
    =======================
    SELECT  distinct
    T0.[TransType], T0.[DocDate],  T0.[InQty], T0.[OutQty], T0.[Dscription], T0.[CalcPrice], T0.[ItemCode] FROM [dbo].[OINM]  T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[DocDate] >= {?DateInicial} and  T0.[DocDate] <= {?DateFinal} and T1.[Canceled] = 'N'
    Query 2
    =========================
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >={?Data1}
    select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <={?Data2}
    Select a.Itemcode, max(a.Dscription) as ItemName,
    sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
    ((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM
    from( Select N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
    as OpeningBalance, 0 as INq, 0 as OUT
    From dbo.OINM N1

    try this
       Declare @ItmsGrpNam varchar(100)
    Declare @Whse nvarchar(10)
    Declare @Fromdate Datetime
    Declare @Todate DateTime
    select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >=[%0]
    select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <=[%1]
    select @Whse = Max(s3.Warehouse) from dbo.OINM S3 Where S3.Warehouse = [%2]
    Select  a.Itemcode, max(a.Dscription) as ItemName,
    (Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,
    sum(a.OpeningBalance) as OpeningBalance,
    ((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing
    from( Select  N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
    as OpeningBalance, 0 as INq, 0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
    inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
    Where N1.DocDate < @FromDate and N1.Warehouse = @Whse and  b.ItmsGrpNam = @ItmsGrpNam
    Group By N1.ItemCode,
    N1.Dscription Union All select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,
    sum(N1.inqty) , 0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
    inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
    Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate
    and N1.Inqty >0  and N1.Warehouse = @Whse and  b.ItmsGrpNam = @ItmsGrpNam Group By N1.ItemCode,N1.Dscription
    Union All select  N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT
    From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
    inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
    Where N1.DocDate >= @FromDate
    and N1.DocDate <=@ToDate and N1.OutQty > 0 and N1.Warehouse = @Whse and  b.ItmsGrpNam = @ItmsGrpNam
    Group By N1.ItemCode,N1.Dscription) a, dbo.OITM I1 ,OITB b1
    where a.ItemCode=I1.ItemCode
    and I1.ItmsGrpCod = b1.ItmsGrpCod
    Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam 
    Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
    Order By a.Itemcode 

  • Need Query for Item Relationship of Oracle Apps

    Hello Team,
    I need the Query to select the Item Relationship.
    In Oracle Apps we have different tyes of Structure
    ItemA -> ItemB
    ItemB -> ItemC
    ItemC -> ItemD
    ItemG -> ItemH
    ItemK -> ItemL
    ItemW -> ItemQ
    and this also is possible (meand many to one relationship)
    ItemA -> ItemB
    ItemB -> ItemC
    ItemC -> ItemD
    ItemT -> ItemD
    and in the Select Query i want the below result
    ItemA -> ItemB 1
    ItemB -> ItemC 2
    ItemC -> ItemD 3
    ItemG -> ItemH 1
    ItemK -> ItemL 2
    ItemW -> ItemQ 1
    and this also is possible (means many to one relationship)
    ItemA -> ItemB 1
    ItemB -> ItemC 2
    ItemC -> ItemD 3
    ItemT -> ItemD 1
    means i want the Hierarchy number also
    Please help me to in order to get the relationship by sql query.
    Kind Regards,

    thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today.  i'll do that now though.
    what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system.  there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
    i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc?

  • Query for items on hold and items that are inactive for past 18 months.

    Hi Experts,
    We are on the process of initializing a new database due to database size, our client requested that we extract items from the current live database but only those items that are not On Hold and has been active for past 18 months. Those items that does not have transaction for the past 18months and currently on hold will be dropped. What will be the query to extract based on this filter? Please help. Thank you.
    Regards

    Hi,
    You may try this first:
    Select  t0.itemcode, t0.itemname, t0.onhand
    from dbo.oitm t0
    where t0.itemcode not in
    (select distinct itemcode from dbo.oinm  where DateDiff(DD,DocDate,GetDate()) < 548 group by itemcode)
    and t0.InvntItem = 'Y' and t0.Frozenfor = 'Y'
    Thanks,
    Gordon

  • QUERY FOR ITEM PROPERTIES

    hello ,
    i need to know how to do a query that shows the item info
    itemcode     itemname     dept     properties
    itema           testa            acc      dining                  (qry group #_)
    itema           testa            acc      patio                    (qry group #_)
    itemb           testb            fur        entcenter            (qry group #_)
    so if itema has 5 properties list them one line each instead of one line and different columns for different property.
    as for the acc and fur does are the itemgroup name instead of the numbers.  
    any help is greatly appreciated.
    thank you.

    select src.ItemCode,src.ItemName,src.ItmsGrpNam
    from
    (select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup1 = 'Y' and OITG.ItmsTypCod = 1
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup2 = 'Y' and OITG.ItmsTypCod = 2
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup3 = 'Y' and OITG.ItmsTypCod = 3
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup4 = 'Y' and OITG.ItmsTypCod = 4
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup5 = 'Y' and OITG.ItmsTypCod = 5
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup6 = 'Y' and OITG.ItmsTypCod = 6
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup7 = 'Y' and OITG.ItmsTypCod = 7
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup8 = 'Y' and OITG.ItmsTypCod = 8
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup9 = 'Y' and OITG.ItmsTypCod = 9
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup10 = 'Y' and OITG.ItmsTypCod = 10
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup11 = 'Y' and OITG.ItmsTypCod = 11
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup12 = 'Y' and OITG.ItmsTypCod = 12
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup13 = 'Y' and OITG.ItmsTypCod = 13
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup14 = 'Y' and OITG.ItmsTypCod = 14
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup15 = 'Y' and OITG.ItmsTypCod = 15
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup16 = 'Y' and OITG.ItmsTypCod = 16
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup17 = 'Y' and OITG.ItmsTypCod = 17
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup18 = 'Y' and OITG.ItmsTypCod = 18
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup19 = 'Y' and OITG.ItmsTypCod = 19
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup20 = 'Y' and OITG.ItmsTypCod = 20
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup21 = 'Y' and OITG.ItmsTypCod = 21
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup22 = 'Y' and OITG.ItmsTypCod = 22
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup23 = 'Y' and OITG.ItmsTypCod = 23
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup24 = 'Y' and OITG.ItmsTypCod = 24
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup25 = 'Y' and OITG.ItmsTypCod = 25
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup26 = 'Y' and OITG.ItmsTypCod = 26
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup27 = 'Y' and OITG.ItmsTypCod = 27
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup28 = 'Y' and OITG.ItmsTypCod = 28
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup29 = 'Y' and OITG.ItmsTypCod = 29
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup30 = 'Y' and OITG.ItmsTypCod = 30
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup31 = 'Y' and OITG.ItmsTypCod = 31
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup32 = 'Y' and OITG.ItmsTypCod = 32
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup33 = 'Y' and OITG.ItmsTypCod = 33
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup34 = 'Y' and OITG.ItmsTypCod = 34
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup35 = 'Y' and OITG.ItmsTypCod = 35
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup36 = 'Y' and OITG.ItmsTypCod = 36
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup37 = 'Y' and OITG.ItmsTypCod = 37
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup38 = 'Y' and OITG.ItmsTypCod = 38
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup39 = 'Y' and OITG.ItmsTypCod = 39
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup40 = 'Y' and OITG.ItmsTypCod = 40
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup41 = 'Y' and OITG.ItmsTypCod = 41
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup42 = 'Y' and OITG.ItmsTypCod = 42
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup43 = 'Y' and OITG.ItmsTypCod = 43
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup44 = 'Y' and OITG.ItmsTypCod = 44
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup45 = 'Y' and OITG.ItmsTypCod = 45
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup46 = 'Y' and OITG.ItmsTypCod = 46
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup47 = 'Y' and OITG.ItmsTypCod = 47
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup48 = 'Y' and OITG.ItmsTypCod = 48
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup49 = 'Y' and OITG.ItmsTypCod = 49
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup50 = 'Y' and OITG.ItmsTypCod = 50
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup51 = 'Y' and OITG.ItmsTypCod = 51
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup52 = 'Y' and OITG.ItmsTypCod = 52
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup53 = 'Y' and OITG.ItmsTypCod = 53
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup54 = 'Y' and OITG.ItmsTypCod = 54
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup55 = 'Y' and OITG.ItmsTypCod = 55
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup56 = 'Y' and OITG.ItmsTypCod = 56
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup57 = 'Y' and OITG.ItmsTypCod = 57
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup58 = 'Y' and OITG.ItmsTypCod = 58
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup59 = 'Y' and OITG.ItmsTypCod = 59
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup60 = 'Y' and OITG.ItmsTypCod = 60
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup61 = 'Y' and OITG.ItmsTypCod = 61
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup62 = 'Y' and OITG.ItmsTypCod = 62
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup63 = 'Y' and OITG.ItmsTypCod = 63
    union all
    select OITM.ItemCode,OITM.ItemName,OITG.ItmsGrpNam
    from OITM CROSS JOIN OITG
    where OITM.QryGroup64 = 'Y' and OITG.ItmsTypCod = 64) src
    order by src.ItemCode

  • Query for a value result when no rows found

    Kindly help me out when I use following query it return no record but I want 0 against this query how plz let me know
    select b.accode,decode(sum(b.debit),null,0,sum(b.debit)) op_dr,
    decode(sum(b.credit),null,0,sum(b.credit)) op_cr,
    c.actitle
    from v_mast a, v_det b, chart c
    where a.v_type=b.v_type
    and a.vouchno=b.vouchno
    and b.accode=c.accode
    and a.VOID='F'
    and a.posted_by is not null
    and a.v_date between '01-JAN-06' and '31-JAN-06'
    and b.accode in (select accode from account where open='T')
    and b.accode in (select accode from chart)
    and a.v_type in ('RN','PV','CV','RV','JV')
    and b.accode = '3050571'
    group by b.accode,c.actitle
    order by b.accode
    Result is : No rows found but is there any possibilities that it will give me following result
    Accode op_dr op_cr
    3050571 0 0

    Why not respond to the earlier threads ?
    Query
    and
    0 when no records found
    Regards,
    Rob.
    Message was edited by:
    Rob van Wijk
    PS: Of course you could do a
    <your query> union all select 3050571,0,0,null from dual
    It answers the question, but I doubt that this is what you want.

  • Need query for Item - Price Change History

    I need help finding information around Price Change History by Price List. 
    Information of interest is Date of Update and By Whom.    Also, if a Datasource is 'N-Unknown', what does this generally mean?
    select
    i.itemcode,
    i.itemname,
    iphist.price,
    pl.listname,
    pl.datasource as 'ChangeSource',
    '' as 'PriceChangeUpdateDate',
    '' as 'UpdateByUser'
    from  ait1 iphist, oitm i, opln pl
    where 1=1
    and iphist.pricelist = pl.listnum
    and i.itemcode = iphist.itemcode
    and iphist.itemcode in ('1234')
    and pl.listnum in (6)
    thanks in advance...

    thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today.  i'll do that now though.
    what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system.  there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
    i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc?

Maybe you are looking for

  • HTML output and missing graph

    I am developing a report having a graph in BI Publisher 10.1.3.3.0. When the report o/p is genereated to PDF, the graph is showing up, but the same report doesnt return the chart in HTML output (it shows small icon in the place of graph). I followed

  • How do I go about picking my favorite song 'Songs of Life' by Neil Diamond and pay for the tune? Please help

    I want to select 'Songs of Life' by Neil Diamond and pay for the tune. I could not locate the karaoke version. Please help!

  • To have one or two environments for sap bpc 10

          Hi all,      My company has implemented the model the Planning, now want to implement the model Consolidation,      my question is if it is better have everything in the same environment or have an environment for planning and other for consoli

  • SCSM 2012 - Deleting deleted items

    I have never deleted the items held in the Deleted Items folder. There are currently 10008 configuration items in there.  I have always been a bit worried about deleting these, I'm not sure if I will lose details of the incidents logged for those use

  • Search/filtering within playlists feature removed

    Hi, Spotify updated itself yesterday to version 1.0.1.988.g8f17a348. The UI got overhauled and few features got removed but the most annoying thing about the change was the disappearance of searching/filtering within a playlist. CMD + F doesn't do an