Performing math on Decode function tags and moving averages

I have a query shown below to create columns for my report. Can I use the field names as shown in bold to perform math functions? Is there an easy way to do this?
select Data_date,
SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL))"TE_Flow_mgd",
SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL))"TE_BOD_mgl",
"TE_FLOW_mgd" * "TE_BOD_mgl" * 8.34*.45359 as "KG_BOD"FROM daily_tag_data
Where data_date >= to_date('12/31/2002','mm/dd/yyyy')
GROUP BY data_date;
Also how would I perform a seven day moving average on "KG_BOD"
Thanks - Very new at this.

If you want avoid a sub-query, try this...
select Data_date,
SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL))"TE_Flow_mgd",
SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL))"TE_BOD_mgl",
SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL)) * SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL)) * 8.34*.45359 "KG_BOD"
FROM daily_tag_data
Where data_date >= to_date('12/31/2002','mm/dd/yyyy')
GROUP BY data_date;
just replace the 'column-alias' with the actual arithmetic fuction...

Similar Messages

  • Standarad price and moving average price

    What is the diff between Standarad price and moving average price ???
    Somasundaram

    Price Control V or S in material type
    When is it useful to use the price control V or S in Material Master ? 
    Do I have to follow the SAP standard setting in the material type for the following material types:
    - ROH(Raw materials) -> moving average price
    - HALB(Semifinished products) -> standard price
    - FERT(Finished products) -> standard price
    In which case and why is useful to change these standard setting in material type?
    What is difference between standard price and moving average price? 
    When and how to use it?
    Standard price are used for products that do not fluctuated frequently.  It is usually used for finished or semi finished products.
    Moving average price are used mainly for raw materials that are purchased externally.  The advantage of using moving average price for your raw materials is that your inventory costs will always reflect the current market cost.
    SAP strongly recommends that you do not select price control V for semi-finished products and finished products, because doing so will very easily cause the calculation of unrealistic valuation prices. SAP recommends: 
    Price control V for raw materials and trading goods; price control S for semi-finished products and products.
    If you nevertheless select price control V, take care in the following situations:
    1. Unrealistic prices occur if materials are produced and also retire during one period (that is, the inventory at the end of the period is smaller than the total of aquisitions from production orders) and if, in addition, several production orders belonging to a material were finished in this period, and the production order settlement calculates variances at the end of the period. Every single production order carries out an inventory coverage check and may therefore cause the moving average price to be changed. However, the individual production orders do not check whether the inventory available at the end of the period has already been debited by another production order. 
    Example: on 20 workdays in the period, 1 piece of material xyz was produced for each day and delivered to the warehouse at a price of USD 1000. At the end of the period there is 1 piece at the warehouse. Since an activity price of a participating cost center was higher than planned , every single production order calculates cost of goods manufactured of USD 1100 during the settlement. Every single one carries out a inventory coverage check and finds out that the variance can be posted completely to the inventory. That is, the ending inventory of one piece is debited with USD 20 x 100 and it consequently receives a price of USD 3000. 
    1. A settlement is carried out although not all costs have yet been posted to the order. This can even result in a price of 0 for the delivered product.
    2. No period check of the costs is carried out on the order, that is, costs from previous periods may be settled.
    3. Settling orders is already possible in the 'Delivery completed' status.
    Solution: Standard price for products together with possible manual price changes.
    If you are required to valuate semi-finished and finished products with actual prices that correspond to the costs of the actual production, SAP recommends you use the function of the material ledger for this. Here, a periodic actual price is created that is calculated on a much more reliable basis than the moving average price. A so-called price limiter quantity is used which makes sure that in the above example price differences are proportionally taken into account (95% of the total price differences) when valuating the 19 pieces withdrawn from material xyz which results in a periodic actual price of 1100 USD. In addition, it is possible as of Release 4.5 to even take into account the variances of the actual prices of the raw materials in the valuation of the semi-finished and finished products that are manufactured from it. 
    If we select std price for any type of material or mav and then make po, it will pick from material master or what?
    The Purchase Info Record have the FIRST priority.  When no po info record is found, the Purchase Order will pick the user LAST enter price.  The PO module do not pick up any price from material master.
    Regards,
    Ashok

  • Standard and Moving Average Price in Material Master

    Hello,
    Can any one please tell the basic difference between Standard and Moving Average price? both the cases how the Material Price is calculated?
    And please provide the accounting entry's also.
    Thanks

    Dear S McIntosh,
    You may check URL below that explain the difference between MAP and Standard price.
    http://help.sap.com/saphelp_47x200/helpdata/EN/47/60ff0749f011d1894c0000e829fbbd/frameset.htm
    Regards,
    ian Wong

  • Stock of material and moving average price for each valuation type

    Hi
    Is anybody aware of any standard report which will show the stock of material and moving average price of the material for each valuation type.
    M5BL is one report but would like to check if there is any other report.
    Regards
    Vaibhav Mahajan

    Hi,
    Check MB52, select 'Display batch stock' option.
    Batch is nothing but your valuation type.
    You can see those details there.
    Regards,
    Piyush

  • Difference between Standard Pricing and Moving Average Price

    Hi,
    Would like to seek some advises on the difference between standard price and Moving average price.
    also, how does it affect the account postings differently?
    Thanks

    Standard Price
    Materials whose price control indicator is set to S are valuated in Financial Accounting (FI) at standard price.
    This is recommended for semifinished products and finished products.
    The moving average price is shown as a statistical value in the material master record.
    The standard price is normally calculated using a standard cost estimate for the material. The standard price can also be calculated in a mixed cost estimate.
    Moving Average Price
    When materials whose price control indicator is set to V are received from in-house manufacturing processes, they are initially valuated with a value you defined (such as the standard price). When you settle, the material stock account is debited with the variances. This results in a new moving average price.
    Valuating semifinished products and finished products with the moving average price is not recommended.
    Regards,
    Indranil

  • Standard and Moving average Price

    Hi,
        What is the Difference between Standard and Moving Avg Price, What are the Cases will we use Standard  Price ,and what are cases shall we use Mov.avg Price, Please Explain me with Example.

    Hi Lakshmi,
    Moving average price is maintained for all the outside procured materials and standard price is maintained for all inhouse manufactured materials...
    We need to run standard cost estimate monthly to update the prices of all the materials with price control S... Prices of materials with price control V will get updated as soon as we do GRN for the materials on the weighted average method...
    Regards
    Raj

  • VMI and moving average price

    Dear all
    Please help us.
    We will use moving average price as stock evaluation.
    Also, we manage all inventory is VMI stock.
    Our business process is the following procedure.
    1. We will increase consignment stock (VMI) without reference to purchase order.
    2. We will input sales order and allocate it to VMI stock.
    3. We will post goods issue, movement type 601-K.
    As you know, accounting documents post GR/IR at this time. Unfortunately, SAP does not calculate moving average price (MAP) in material master. ie. moving average price is zero.
    We would like to calculate moving average price because almost stock is VMI.
    How do you customize SAP?
    Best regards.

    You have to add one more step to handle this scenario as per my knowledge
    which is before you issue the stock using 601 K you have to take the stock in you own inventory and than issue using movement type 601 not 601 k.
    As per the std SAP the 601 K M type will never update the value  because that's not are stock
    you can see the setting below
    601     K     L                   2             VAX
    601     K     L          WA03     2     GBB     VAX
    601     K     L     E              2             VKA
    601     K     L     E     WA03     2     GBB     VKA
    601     K     L     P              2             VKA
    601     K     L     P     WA03     2     GBB     VKA
    601     K     L     V              2             VAY

  • REM wip and moving average price

    Hi,
    I am working in REM scenario. my fert item is having moving average price say Rs 2.Currently zero stock of finished item. I am having a planned orderA quantity 10  from Oct 1st to nov 30th. when i do backflush at nov 30 , i do assembly backflush and post auto GR of 10 quantity. after doing settlement, i got my moving average price as Rs12.
    I have another planned order B for quantity 20, same finished item from oct 15th to dec15th. On nov 30th when i am doing component backflush or activity backflush of second planned order( i am not doing assembly backflush on nov 30 because this order is not yet completed, it will complete on 15th December), system is posting all cost on my existing stock of finished item and increasing the moving average price of finished item from Rs 12 to Rs 17.
    But this is wrong because cost should not exceed for existing stock, cost should be posted for WIP..
    Please tell me how to correct this?
    how to calculate WIP in REM? is it mandatory to go for reporting backflush? i have only one operation in my rate routing i.e labor hours is my only operation  in 0010.
    Regards.

    Hi,
    Thanks for ur help.
    But my doubt is something different!
    If i have a planned order' A'( qty 10)which is completed in Novemeber month and another planned order 'B' ( qty 20) which is still in WIP on November end, and at this stage if I do backflush for planned order A, cost flows properly and finished item is put in stock with some moving average price.But when i book labor hours again for planned order B, it books cost. But this time i do not do assembly backflush because production is not yet finsihed.so stock quantity is still the old one i.e 10 qty.So second cost booking goes to the stock item of 10 qty and increases the moving average price. system dfoesnt understand that second labor hours is booked for second planned order . this is happening because both planned orders are of same finished item.
    please reply.
    please tell me what is the way to do reporting backflush. what settign we need to do? can it solve my issue?? because my target is to book cost in case of second planned order as WIP and do NOT effect the moving average price of existing stock.
    Regards.

  • Freight and moving average

    I set up freight with Distribution method (Quantity) and Drawing Method (Quantity).
    If I use this freight on a purchase invoice line the last purchase price is correctly update but on the inventory evaluation (using moving average) the system do not consider freight.
    I do not use perpetual inventory.
    Thanks

    Hi,
    The concept my not exsist but on the inventory evaluation I have the possibility to select the moving average. And all ather things is consider in the mouving average: ex landed cost. Is only the freight that is not included.
    You think that is an error that I have the moving average as evaluatin method choise?

  • Affect of discount on COGS and moving average prices

    Hi experts,
    I want your suggestion to build following scenario in SAP;
    Case: During purchase order, vendor has given special discount for a material when purchased for a specific customer.
    Requirement: I need to know following;
    1. How are those specific prices could be reflected in COGS?
    2. How do those specific prices affect the moving average price? is there any way to avoid this effect in the COGS?
    Thanks

    Hi Pirzada
    Considering that you are working with material ledger system will calculate moving average price doesn´t matter the discounts conditions you had during month.
    System will revaluate all consumption considering this moving average price.
    Maybe you could think about Splliting Valuation feature ou  Make to Sales Order scenario.
    These are ways to have a specific cost using the same part number.
    Regards
    Fred

  • DECODE function with ' ' and ' '

    I need of a command to compare intervals of dates, similar to DECODE, only that using '<' and '>'.
    Example: if the date will be minor who ' 2005-10-01 ' then return ' problem ', else if the date will be minor who 2005-11-01 and greater that 2005-10-01, then returns ' ok '
    I tried to use the function ' decode ' with the function ' sign ', but this only functions for numbers and it does not stop dates.
    Former: Using a column that contains numbers, ok.
    SELECT decode(SIGN(col_number-10),-1,'<10',decode(SIGN(col_number-20),-1,'<20',decode(SIGN(col_number-30),-1,'<30'))) col_number
    FROM table
    If to use a column that contains dates (dates or timestamp), problem (types of incosistentes dates: it waited NUMBER got YOU DATE).
    SELECT decode(SIGN(col_date-10),-1,'<10',decode(SIGN(col_date-20),-1,'<20',decode(SIGN(col_date-30),-1,'<30'))) col_date
    FROM table
    Somebody has some idea?

    Somebody has some idea?Yes, CASE().
    Cheers, APC

  • Function key and moving the columns in a table

    Hi all,
    Can anyone help me how to make use of function key UI element in nwds 7.1 ehp1 version..
    and also how to move the columns of the tables at run time...
    thanks,
    viswa

    No,
    i am not working on mobiledevices...
    i am recently installed this nwds 7.1 ehp1 version  and learning the new things in that...
    for that purpose i am searching for the pdf's or examles here...
    can anyone pls send me the tutorials or samples to work on it
    thanks,
    viswa

  • Costing with Standard and Moving Average Price

    Hello All,
    I understand that SAP recommends Std Price for Semi Finished /Finished goods and MAP for trading goods and raw materials.
    How does costing takeplace when it includes both the materials - semi finished and trading goods.
    Is it possible at all?
    Any suggestions will be helpful.
    Thank You,
    Andy

    Hiya,
    You may want to frame your question differently.
    When what(?) contains SF and Trading Goods? BOM? Costing Run?
    The Std Price and MAP you mentioned are the Price Control Indicators. These dictate the price to use and the treatment required for the material (realtime stock value updation during the month with GR/GI for MAP and no value updates for SP).
    By itself, it does not affect the costing of (say) a BOM containing both these materials together... the system determines what price to use and costs the product accordingly.
    Cheers.

  • What is the differents bet ween standard price and moving average price

    hi

    Hi,
    Check the below link....
    http://help.sap.com/saphelp_47x200/helpdata/en/53/5df779aa3011d295a200a0c930328a/frameset.htm
    Regards,
    Putty

  • How do I add moving averages to my time series graph is there a function on numbers on tr iMac?

    I've created a time series graph on numbers on my iMac but I need to add moving averages. Is there a function an if so where is it and if not is there a way to get around it

    Badunit,
    Here is an example plot, data sorted from most recent data at top of the table...
    You can see the moving average (of 20) is plotted from right to left.
    The Moving Average calculation is now wrong, and should have been calculated and presented from oldest to most recent.
    Here is the same data, with table sorted from oldest data at the top of the table.
    The moving average is also plotted from right to left, and shows the correct Moving Average for the most recent data.
    That is, it is calculated from oldest to most recent, with the last Moving Average data point plotted on "todays" date.
    What I want to see is my table displayed from most recent at the top (the top table), and moving average calculated and displayed as per the bottom graph.
    Edit: So, think about this some more,
    I need an option to tell Numbers to do the Moving Average calculation from the bottom of the table up, not from the top of the table down.

Maybe you are looking for

  • Oracle DB Adapter 11g detect omissions

    Hi, We are trying to use the detect omissions property in Oracle Database adapter 11.1.1.5.We are integrating with DB2.But detect omission does not remove the tags having empty values and we get errors that null value is not expected in the field. Th

  • IPod goes straight to "Ok to disconnect"

    Soon as I plug my gen 2 iPod into my windows machine it goes straight to "Ok to disconnect". This hasn't always been the case, as it's only started doing it today. I was putting some new tracks onto it and it didn't get all the way though before it e

  • I am using JComboBox.i want ihe JComboBox popup always in top direction.

    Hi friends, i am using JComboBox.i want ihe JComboBox popup always in top direction(like mobile options ).by default JComboBox popup always in down direction.plz help me

  • App update freezes

    During an app update on my iPad, the update froze. I have tried a re-set, I've powered on and off, I've shut the app down, I've signed in and out of iTunes. Nothing helps, still frozen. I'd like to just delete the app, but there doesn't seem to be a

  • Expdp/impdp a partitioned DB

    Hi, I'm importing a full DB with partitioned tables but have errors like this: ORA-31693: Table data object "SOMETHING"."SS_TRANSACTION_HIST":"SS_TRANSACTION_HIST_0907" failed to load/unload and is being skipped due to error: ORA-02354: error in expo