Results 1 to 2 of 2

Thread: greater value

  1. #1
    Join Date
    Sep 2011
    Posts
    220

    Unanswered: greater value

    Hi,

    DB2 V9.5/Z/OS

    How to check greater value in the set of values


    SELECT CK_FLIP FROM BASE_TABLE

    WHERE BR_VALUE > ('123','345','453','121','99','33')

    BASE TABLE

    CK_FLIP BR_VALUE

    AAA 31
    AAB 21
    BBB 500
    CCC 11

    EXPECTED OUTPUT

    BBB

    Thanks,

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    try this:
    Code:
    with BASE_TABLE (CK_FLIP, BR_VALUE) as (
              select 'AAA',  31 from sysibm.sysdummy1
    union all select 'AAB',  21 from sysibm.sysdummy1
    union all select 'BBB', 500 from sysibm.sysdummy1
    union all select 'CCC',  11 from sysibm.sysdummy1
    )
    , PARAMS (BR_VALUE) as (
              select 123 from sysibm.sysdummy1
    union all select 345 from sysibm.sysdummy1
    union all select 453 from sysibm.sysdummy1
    union all select 121 from sysibm.sysdummy1
    union all select  99 from sysibm.sysdummy1
    union all select  33 from sysibm.sysdummy1
    )
    select CK_FLIP
    from BASE_TABLE
    where BR_VALUE > (select max(BR_VALUE) from PARAMS);
    order by BR_VALUE desc
    fetch first 1 row only;
    Regards,
    Mark.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •