MS-SQL > DISTINCT¸¦ ÀÌ¿ëÇÑ Áߺ¹ Á¦°Å µî·ÏÀÏ : 2017-06-30 17:15 Á¶È¸¼ö : 52,526SELECT ÀνºÆ®·°¼ÇÀº µµÇ¥ÁßÀÇ Çϳª ¶Ç´Â ¿©·¯°³ ÇʵåÀÇ ¸ðµç µ¥ÀÌÅ͸¦ ÀÐÀ»¼ö ÀÖ°Ô ÇÕ´Ï´Ù.
ÇÏ¿© µ¥ÀÌÅÍ Áߺ¹¿©ºÎ¿Í °ü°è¾øÀÌ ¸ðµç µ¥ÀÌÅ͸¦ ã¾Æ³¾¼ö ÀÖ½À´Ï´Ù.µ¥ÀÌÅÍ Ã³¸® °úÁ¤Áß µµÇ¥³»ÀÇ ºÎµ¿ÇÑ µ¥ÀÌÅͼöÄ¡¸¦ ã¾Æ³»¾ßÇÏ´Â °æ¿ì°¡ ¸¹½À´Ï´Ù. ´Ù½Ã¸»ÇÏ¸é µµÇ¥/Çʵ峻¿¡ ¾î¶² ºÎµ¿ÇÑ ¼öÄ¡°¡ ÀÖ´ÂÁö ¾Ë¾Æ¾ß ÇÏ°í ÃâÇö ȸ¼ö´Â Áß¿äÇÏÁö ¾ÊÀ»°æ¿ì¿¡´Â ¾î¶»°Ô ÇؾßÇÒ°¡¿ä? SQLÁß¿¡¼´Â ¾ÆÁÖ ½±°Ô ÇÒ¼ö ÀÖ½À´Ï´Ù. SELECT µÚ¿¡ DISTINCT ¸¸ Ãß°¡ÇÏ¸é µË´Ï´Ù. T_DB Å×À̺í
colum01, colum02 ÀÇ Å×À̺íÀÇ µ¥ÀÌÅÍ°¡ À§¿Í °°ÀÌ ÁغñµÇ¾î ÀÖÀ» ´Ù. ÀÌ µ¥ÀÌÅÍÀÇ Áߺ¹À» ÇÇÇؼ °ªÀ» Ãâ·ÂÇÏ°í ½ÍÀ»¶§ DISTINCT ¸í·É¸¸ »ç¿ëÇÏ¸é ½±°Ô ÇØ°á ÇÒ ¼ö ÀÖ´Ù. °á°ú °ª ------------------------------------------------------------------------------------- 1111 , 1111 1111 , 2222 1111 , 3333 1111 , 4444 2222 , 4444 SELECT DISTINCT colum01,colum02 FROM T_DB Áߺ¹Àç°Å °¹¼ö¸¦ »Ì°í ½ÍÀ¸¸é SubQuery ¸¦ ÀÌ¿ëÇؼ count¸¦ »ÌÀ» ¼ö ÀÖ´Ù.
|