1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Get unique values

Discussion in 'SQL PL/SQL' started by akika, Sep 13, 2017.

  1. akika

    akika Active Member

    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    80
    Location:
    New Delhi
    hi,
    from foll. select, how can i get unique values for screen_type and screen

    select a.EMP_NO,a.SCREEN, b.SCREEN_TYPE
    from EMPLOYEE_TAB a, SCREEN_TAB b
    where a.id = b.ID
    and SCREEN_TYPE like '%S';

    EMP_ID SCREEN SCREEN_TYPE
    EMP_123 SCR100 SCRTYPE100S
    EMP_124 SCR100 SCRTYPE100S
    EMP_125 SCR100 SCRTYPE100S
    EMP_127 SCR102 SCRTYPE102S
    EMP_128 SCR102 SCRTYPE102S
    EMP_135 SCR102 SCRTYPE102S
    EMP_136 SCR102 SCRTYPE102S
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    715
    Likes Received:
    143
    Trophy Points:
    830
    Location:
    Russian Federation
    What does it mean to get unique values ?

    Code (Text):

    WITH your_data (EMP_ID, SCREEN ,SCREEN_TYPE) AS
    (

    SELECT 'EMP_123', 'SCR100' ,'SCRTYPE100S' FROM dual UNION ALL
    SELECT 'EMP_124', 'SCR100' ,'SCRTYPE100S' FROM dual UNION ALL
    SELECT 'EMP_125', 'SCR100' ,'SCRTYPE100S' FROM dual UNION ALL
    SELECT 'EMP_127', 'SCR102' ,'SCRTYPE102S' FROM dual UNION ALL
    SELECT 'EMP_128', 'SCR102' ,'SCRTYPE102S' FROM dual UNION ALL
    SELECT 'EMP_135', 'SCR102' ,'SCRTYPE102S' FROM dual UNION ALL
    SELECT 'EMP_136', 'SCR102' ,'SCRTYPE102S' FROM dual
    )

    SELECT SCREEN ,SCREEN_TYPE
    FROM your_data
    GROUP BY SCREEN ,SCREEN_TYPE;