Geting value count from an Oracle Table

后端 未结 2 1175
忘了有多久
忘了有多久 2021-01-19 17:03

I have a table, that contains employees. Since the company I\'m working for is quite big (>3k employees) It is only natural, that some of them have the same names. Now they

相关标签:
2条回答
  • 2021-01-19 17:14

    This can be easily done with a count over partition:

    SELECT NAME, SURNAME, USERNAME, COUNT(*) OVER (PARTITION BY NAME, SURNAME)
    FROM
    YOUR_TABLE;
    
    0 讨论(0)
  • 2021-01-19 17:15

    Adding the flag to Daniel's answer...

    SELECT NAME, SURNAME, USERNAME, DECODE(COUNT(*) OVER (PARTITION BY NAME, SURNAME), 1, 'N', 'Y')
    FROM
    YOUR_TABLE;
    

    Please note that Oracle SQL has no support for booleans (sigh...)

    0 讨论(0)
提交回复
热议问题