Forum Discussion

Darius_BD's avatar
Darius_BD
Copper Contributor
May 31, 2022

sql query

Hello, maybe someone could help.

I got 2 different ProdCode 2004 and 3069. I need for BazineKaina get value from I33_KODAS_IS =02 

For ProdCode 2004 I need get all BazineKaina 2.5500

For ProdCode 3069 I need get all BazineKaina 13.5100

Query I use:

SELECT
'.'+I33_KODAS_PS+'.' as ProdCode,
I33_KODAS_IS,
i33_kaina,
case when i33_kodas_is in ('02') then i33_kaina when i33_kodas_is not in ('02') then i33_kaina end as BazineKaina
FROM I33_PKAI

 

3 Replies

  • Hi Darius_BD -- I'm not sure that I fully understand either, but is something like the query below achieve your desired result?  Take care.

    
    SELECT
    ProdCode,
    I33_KODAS_IS,
    CASE
    WHEN I33_KODAS_IS IN ('02') THEN I33_KAINA
    WHEN I33_KODAS_IS NOT IN ('02') THEN (SELECT I33_KAINA FROM I33_PKAI WHERE I33_KODAS_IS='02' AND A.ProdCode=ProdCode)
    END AS BazineKaina
    FROM
        I33_PKAI A
    ORDER BY ProdCode,I33_KODAS_IS

     

     

  • olafhelper's avatar
    olafhelper
    Bronze Contributor
    Sorry, but for me is your post not clear.
    Please post table design as DDL, some sample data as DML statement and the expected result.

    Olaf

Resources