Select Rows with same field

  • HI,

    I have the following statement :

    select

    CSK_PRODUCTID,csk_quantity,T.loc_code,y.CLC_ID

    from lv_countstock

    inner join lv_product on prd_id=csk_ProductID

    inner join LV_ProductLang with(nolock) on prd_id=prdl_productid

    inner Join Lv_Count On cnt_id=csk_countid

    inner Join lv_countPlanLocation Y on Y.clc_id=cnt_CountPlanLocID

    inner join LV_CountPlan with(nolock) on cpn_id=clc_CountPlanID

    inner join lv_location (nolock) on clc_LocationID = loc_id

    inner join lv_itemunit (nolock) on csk_ItemUnitID=itu_id

    inner join lv_unit (nolock) on unt_id = itu_unitid

    INNER JOIN lv_productdepositor (nolock) on pdp_productid=prd_id

    inner join lv_depositor (nolock) on dep_id=pdp_DepositorID

    inner join dbo.LV_DepositorParameterLS(nolock) on dep_id = dpl_DepositorID

    inner join V_CountPlanLocation T on T.clc_id=Y.clc_id

    where itu_ConsumerUnitLED=1 and dpl_LogisticSiteID = 2 AND prdl_languageid=2 AND LANGUAGEID=2

    and csk_productid=123489 and cpn_code=05

    group by CSK_PRODUCTID,csk_quantity,T.loc_code,y.CLC_ID

    And I get the result

    CSK_PRODUCTIDcsk_quantityloc_codeCLC_ID

    123489 999.000000 L2.9.5.1 36680

    123489 2067.000000 L2.10.2.0 36537

    123489 2279.000000 L2.10.2.0 36537

    How can I take only the two last records that have the same CLC_ID 36537?

    Thank you,

    John

  • The people here are all volunteers and are more than willing to provide a tested answer to your question, but to do so they need you to help them.

    Your question should contain table definitions with those columns that are included in your T-SQL statement would be adequate.

    Sample data for each table.

    Your existing T-SQL statement should be contained within the IFCode Shortcuts code="sql"][/code [ and ] brackets removed to illustrate the proper shortcut to be utilized

    Please read the first link in my signature block as to help make it easier for those who want to help you

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply