|
|
|
|
Á¤¼ö / 2001-02-20 / ¿ÀÈÄ 2:42:46 / 211.181.157.44
Á¶È¸¼ö : 145
|
[Áú¹®] ´äº¯ÀÔ´Ï´Ù.. |
> ÀÖÀó¾Æ¿©, 俵´Ôµµ º¸¼ÌµíÀÌ Á¦ »çÀÌÆ®¿¡¼
> µµ¼¸ñ·Ï Á¶È¸ ºÎºÐÀÌ ÀÖÀ½´Ù.
> ±Ùµ¥¿© ¿©±â¼ ½Å°£°ú º£½ºÆ®¸¦ ³¯Â¥¿Í Ä«¿îÆ®(ÆǸżö·®)
> À¸·Î ±¸ºÐÇؼ ÀÚµ¿À¸·Î ³Ñ±â°í ½Í¾î¿©.
> ±Ùµ¥¿© ±×ºÎºÐ¿¡¼´Â µµ¹«Áö °¨µµ ¾È¿Í¿©.
> ¹®Á¦´Â ÀúÈñ ±³¼ö´ÔÇÑÅ× µé¾ú´Âµ¥¿©,
> ½Å°£Àº ³¯Â¥ÇÔ¼ö Áï datediff¶ó°í ÇÏ´Â ³ÑÀ» ½á¾ß
> ÇÑ´ë¿ä, ±Ùµ¥¿© ¹®Á¦´Â ÀÌ·±³ÑÀ» Àú´Â ÀüÇô ¸ô·¯¿©.
> ±Û±¸ º£½ºÆ®´Â group by¿Í having¸¦ ½á¾ß
> ÇÑ´ë³×¿©.(À̰͵Π¸ô·¯)
> À̳ѵ鿡 ´ëÇؼ Á¦°¡ ¾Ë¼ö ÀÖµµ·Ï ¼³¸íÁ» ÇØÁֽ÷ƴϱî?
> Áö¼ÛÇÔ´Ù. ¸ÅÀÏ µµÀåÀ» Âï´Â±º¿©.
> ±×·¡µµ ¹Ì¿öÇÏÁö ¾Ê±â......
> Ãß½Å:±ÞÇØ¿©, ¹«Áö¹«Áö ±Ã±ÝÇϰŵ¢¿©.
> ´ä ¿Ã¶§±îÁö Àáµµ ¸øÀÚ¿©. Áö±Ýµµ ´«ÀÌ Ä§Ä§Çϰŵ¢¿©.
> ¾îÁ¦ °Ë»ö´Þ·Á±¸ 4Àϸ¸¿¡ ´Þ¾Ò¾î¿©, ±×·¡¼
> ¶Ç ¹ã»ùÇ߾.
-----------------------------------------------------------
"Group By "´Â ¸»ÀÇ ´À³¦Ã³·³ ±×·ìÀ» ¸¸µç´Ù´Â °ÍÀÔ´Ï´Ù.
¸¸¾à ·¹Äڵ尡 a,b,a,c,c,d ÀÌ·±½ÄÀ¸·Î ÀÖ´Ù°í °¡Á¤Çϸé(Ä÷³À̸§Àº A )
Select A From Table Group By A
À§¿Í °°ÀÌ Äõ¸®¸¦ ´øÁ®ÁÖ¸é
---
a
b
c
d
---
À§ÀÇ ³× °¡ÁöÀÇ ±×·ìÀÌ »ý±â°Ô µÇ´Â °ÅÁÒ..
Select A,Count(*)From Table Group By A
ÀÌ·±½ÄÀ¸·Î Çϸé
----
a 2
b 1
c 2
d 1
----
À¸·Î Ãâ·ÂÀÌ µË´Ï´Ù...
Group By¿¡ ´ëÇؼ´Â ¾Æ½Ã°ÚÁÒ...?
Having ±¸ÀýÀº Group By¿Í¸¸ °°ÀÌ ¾²Àδä´Ï´Ù..
À½..WhereÀýÀÇ ±â´ÉÇÏ°í ºñ½ÁÇÏ´Ù°í »ý°¢ÇÏ½Ã¸é µÇ°Ú³×¿ä...±×·ìÀ» ¸¸µå´Âµ¥, ¸î°¡ÁöÀÇ Á¶°ÇÀ» Á༠¸¸µå´Â ±â´ÉÀÌ µÇ°ÚÁÒ..
Select A,Count(A)From Table Group By A Having Count(A)> 1
À§¿Í °°ÀÌ Çϸé
-----
a 2
c 2
-----
Áï, ±×·ì³»ÀÇ ¼ö°¡ µÎ°³ÀÌ»óÀÎ ±×·ì¸¸ Ãâ·ÂÇ϶ó´Â ¹®ÀåÀÌ µÇ°Ú½À´Ï´Ù.
ÀÌÁ¤µµ¸é Group by, HavingÀÇ Àǹ̴ ÀÌÇØ °¡½Ç ÁÙ ¾Ð´Ï´Ù..
(À§ ¿¹Á¦´Â Á¦°¡ ÀÓÀ¸·Î ¸¸µç°ÍÀÔ´Ï´Ù. µû¶ó¼ Ʋ¸° ºÎºÐÀÌ ÀÖÀ»Áöµµ ¸ð¸£°Ú½À´Ï´Ù.^^*)
Áö±Ý ´Ô²²¼ ÇϽô ÀÛ¾÷ÀÇ ³»¿ëÀ» ÀÚ¼¼ÇÏ°Ô ÀÌÇØ ÇÏÁö ¸øÇϹǷΠ¿¹¸¦ µé¾î ¼³¸í µå¸®°Ú½À´Ï´Ù.
Select * From T_Book Where Datediff(day,S_Date,getdate()) < 7
S_Date´Â ÃâÆÇÀÏÀÚ³ª ¾Æ´Ô µî·ÏÀÏÀÚ°¡ µÇ°Ú½À´Ï´Ù.(Ä÷³ À̸§)
À§¿Í °°ÀÌ Äõ¸®¸¦ ´øÁö¸é ÇöÀç ÀϷκÎÅÍ 7ÀÏ À̳»¿¡ µî·ÏµÈ Ã¥µéÀÇ Á¤º¸°¡ Ãâ·ÂµÇ°Ô µË´Ï´Ù.
Datediff(day,S_Date,getdate())
À§ ¹®ÀåÀº S_Date¿Í ÇöÀçÀÏÀÚ¿ÍÀÇ Â÷ÀÌ ³¯¼ö(day)¸¦ Ãâ·ÂÇÏ°Ô µË´Ï´Ù..
ÀÌÁ¤µµ·Î ÁÙÀÌ°Ú½À´Ï´Ù.
³»ÀÏ Á¹¾÷½ÄÀÌ ÀÖ¾î¼ Áö±Ý °íÇâ¿¡ ³»·Á °¡¾ß Çϰŵç¿ä..(¼¿ï¼ ³×½Ã Â÷·ç..)
°íÇâ¿¡¼ Ãß°¡ÇÒ ¼ö ÀÖÀ¸¸é Ãß°¡ Çϵµ·Ï ÇÏÁÒ...
ÁÁÀº ÇÏ·ç º¸³»¼¼¿ä...
-----------------------------------------------------------
Select TOP 5 * From T_Book Where Datediff(day,S_Date,getdate()) < 7 Order by Ä«¿îÅͼö DESC
ÀÌ·¸°Ô Çϸé 7ÀÏ À̳»ÀÇ ÃâÆÇµÈ ½Å°£µµ¼Áß °¡Àå ¸¹ÀÌ Æȸ° Ã¥ 5±ÇÀ» ³ªÅ¸³»¾î ÁÙ °Ì´Ï´Ù..
|
|
|
|