|
|
|
|
î¤éÞ / 2024-02-26 / ¿ÀÈÄ 1:57:46 / 165.246.204.254
Á¶È¸¼ö : 104
|
[±âŸ] ³ªÀÌ ±¸Çϱâ |
SELECT PAPMI_DOB
, FLOOR(CAST(DATEDIFF(d, PAPMI_DOB, GETDATE()) AS INTEGER)/365.2422) A
, FLOOR(CAST(DATEDIFF(d, DATEADD(d, -1, PAPMI_DOB), GETDATE()) AS INTEGER)/365.2422) B
, CASE
WHEN CONVERT(CHAR(8), GETDATE(), 112) < PAPMI_DOB THEN 0
WHEN YEAR(CONVERT(CHAR(8), GETDATE(), 112)) = YEAR(PAPMI_DOB) THEN 0
WHEN RIGHT(CONVERT(CHAR(8), GETDATE(), 112), 4) >= RIGHT(PAPMI_DOB, 4) THEN YEAR(CONVERT(CHAR(8), GETDATE(), 112)) - YEAR(PAPMI_DOB)
ELSE YEAR(CONVERT(CHAR(8), GETDATE(), 112)) - YEAR(PAPMI_DOB) - 1
END AS C
FROM T_Student_M
³ªÀ̸¦ ±¸Çϱâ À§ÇÑ °ø½ÄÀÌ Àִµ¥ MS-SQL¿¡¼ ÇØ º» °á°ú »ý³â¿ùÀÏ¿¡ µû¶ó
»ýÀÏÀÌ ¾Æ´Ñ »ýÀÏ ´ÙÀ½ ³¯ÀÌ µÇ¾î¾ß ³ªÀÌ°¡ ¾÷µ¥ÀÌÆ® µÇ´Â °ÍÀ» ¾Ë ¼ö ÀÖ¾ú´Ù.
»ý°¢ÇÑ ¹æ¹ýÀº CASE¸¦ ÀÌ¿ëÇϰųª ½ÇÁ¦ »ýÀÏÀ» ÇÏ·ç ¾ÕÀ¸·Î Çؼ °è»êÇÏ´Â °ÍÀÌ´Ù. |
|
|