MS-SQL > Group by µî·ÏÀÏ : 2017-06-30 17:00 Á¶È¸¼ö : 52,5351. Group by
Å×À̺í¸í:table1 num part ----------- 1 0 10 0 11 1 12 2 13 3 17 1 18 0 19 2 20 3 22 2 23 0 24 1 27 0 ---------- part°¡ 0,1,2,3 ÀÌ·¸°Ô µé¾î°¡ ÀÖ½À´Ï´Ù. °¢°¢ÀÇ part°¡ 0,1,2,3¸¶´Ù °¡Àå Å« numÀÇ ¼ö¿¡ °ü·ÃµÈ ¸ðµç °ªµéÀ» »Ì¾Æ³» ·Á°íÇÕ´Ï´Ù. À§ÀÇ ¿¹·Î º¸ÀÚ¸éÀº °á°ú´Â num part ----------- 20 3 22 2 24 1 27 0 ------------ ÀÌ·¸°Ô ³ª¿À°ÚÁö¿ä. select part,number=max(num) from table1 group by part 2. Having GROUP BY ·Î ¹ÀÎ °ªµé¿¡ Á¶°ÇÀ» ºÙÀÌ°í ½Í´Ù¸é? select number,idx,total FROM Å×À̺í¸í GROUP BY idx HAVING sum(total) >= 30 À§ÀÇ Äõ¸®´Â idx¶õ À妽º Çʵ带 ±âÁØÀ¸·Î ±×·ìÀÌ ¹¿©Á® ÀÖ´Ù... ±×·¯³ª, ÀÌÁß totalÀÇ ÇÕ°è°¡ 30ÀÌ»óÀÎ °ªµé¸¸ Ãâ·ÂÀ» ½ÃÄÑÁØ´Ù.
|