๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป ๐ŸŒฎ ๐Ÿ’ฌ
๐Ÿ’ป leetcode/database

[LeetCode] Database | 182. Duplicate Emails

by ๋ฐ”์ฟ„๋ฆฌ 2022. 1. 2.

Problem


 

Example


 

Thinking


ํ…Œ์ด๋ธ”์—์„œ ์ค‘๋ณต์ด ๋˜๋Š” ์ด๋ฉ”์ผ์„ ์ถœ๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

์ค‘๋ณต๋œ ์ด๋ฉ”์ผ์„ GROUP BY๋กœ ๋ฌถ์–ด์ฃผ๊ณ 

HAVING์„ ์‚ฌ์šฉํ•ด์„œ count ๊ฐ’์ด 1 ์ดˆ๊ณผ (ํ˜น์€ 2 ์ด์ƒ)์ธ email ๊ฐ’์„ ๊ณจ๋ผ์ฃผ์ž

 

Solve


์ œ์ถœ ๋‹ต์•ˆ

 

select email as Email from Person
    GROUP BY email
    HAVING COUNT(*) > 1;


 

https://leetcode.com/problems/duplicate-emails/submissions/

 

Duplicate Emails - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com