This discussion is archived
3 Replies Latest reply: Mar 18, 2013 4:13 AM by HamidHelal RSS

Last updated Rate

ADFBeginer Newbie
Currently Being Moderated
Hi,

How do i get the last updated Rate of a product.


select max(cs.updated_at) , cs.cost as landed_cost
from product_config cc, product_Details cs,
where cc.id_product_config = cs.fk_product_config and
and cc.code='CA782fERF93SLA'
group by cs.fk_product_config

The above query give the last updated date , but not the last updated cost.
  • 1. Re: Last updated Rate
    HamidHelal Guru
    Currently Being Moderated
    ADF Beginer wrote:
    Hi,

    How do i get the last updated Rate of a product.


    select max(cs.updated_at) , cs.cost as landed_cost
    from product_config cc, product_Details cs,
    where cc.id_product_config = cs.fk_product_config and
    and cc.code='CA782fERF93SLA'
    group by cs.fk_product_config

    The above query give the last updated date , but not the last updated cost.
    try something like this
    SELECT CS.COST AS LANDED_COST
    FROM PRODUCT_CONFIG CC, PRODUCT_DETAILS CS,
    WHERE CC.ID_PRODUCT_CONFIG = CS.FK_PRODUCT_CONFIG
    AND CC.CODE='CA782fERF93SLA'
    AND CS.UPDATED_AT=(SELECT  MAX(CS.UPDATED_AT)
                        FROM PRODUCT_CONFIG CC, PRODUCT_DETAILS CS,
                        WHERE CC.ID_PRODUCT_CONFIG = CS.FK_PRODUCT_CONFIG
                        AND CC.CODE='CA782fERF93SLA'
                      )
    Hope , it helps

    Hamid

    Mark correct/helpful to help others to get right answer(s).*
  • 2. Re: Last updated Rate
    ADFBeginer Newbie
    Currently Being Moderated
    Hamid,

    The query run very slow when we do it for a table. If we use CC.CODE='CA782fERF93SLA', then it runs faster. But we need to do it for the table
  • 3. Re: Last updated Rate
    HamidHelal Guru
    Currently Being Moderated
    ADF Beginer wrote:
    Hamid,

    The query run very slow when we do it for a table. If we use CC.CODE='CA782fERF93SLA', then it runs faster. But we need to do it for the table
    You need to tune the or try other way.
    First check which part of the query is slow. Iner query or Main query ?
    May trying to indexing on a column. May post on {forum:id=75}


    Hope this helps

    hamid

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points